#include<bits/stdc++.h>

using namespace std;

int main() {
    int n;
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    long long ans=0;    //维护逆序对
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    auto merge=[&](vector<int>&a,vector<int>&b)->vector<int>
    {
        vector<int>res;
        size_t ai=0,bi=0;
        while(ai<a.size()&&bi<b.size()){
            if(b[bi]<a[ai])
            {
                res.push_back(b[bi]);
                bi++;
                ans+=a.size()-ai;         //更新逆序对
            }
            else {
                res.push_back(a[ai]);
                ai++;
            }
        }
        if(ai==a.size())
            res.insert(res.end(),b.begin()+bi,b.end());
        else if(bi==b.size())
            res.insert(res.end(),a.begin()+ai,a.end());
        return res;
    };
    auto merge_sort=[&](auto &&self,vector<int>&arr)->vector<int>{
        if(arr.size()<=1)return arr;
        const size_t mid=arr.size()>>1;
        vector<int> left(arr.begin(),arr.begin()+mid);
        vector<int> right(arr.begin()+mid,arr.end());
        left=self(self,left);
        right=self(self,right);
        return merge(left,right);
    };
    a=merge_sort(merge_sort,a);
    cout<<ans;        //输出逆序对
}