#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstring>
#define ll long long
using namespace std;
ll a[1008611],ans,tmp[1008611];
void Merge(ll l,ll m,ll r){
ll i=l,j=m+1,k=l;
while(i<=m&&j<=r){
if(a[i]>a[j]){
tmp[k++]=a[j++];
ans+=m-i+1;
}
else tmp[k++]=a[i++];
}
while(i<=m)tmp[k++]=a[i++];
while(j<=r)tmp[k++]=a[j++];
for(ll i=l;i<=r;++i)
a[i]=tmp[i];
}
void merge_sort(ll l,ll r){
if(l<r){
ll m=(l+r)/2;
merge_sort(l, m);
merge_sort(m+1,r);
Merge(l,m,r);
}
}
int main(){
int n;
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++){
cin>>a[i];
}
ans=0;
merge_sort(0,n-1);
cout<<ans<<endl;
}
return 0;
}