#include<cstdio>
#include<iostream>
#define N 100100
using namespace std;
int a[N],b[N],n;
long long k;
void binary_chop(int l,int r){
if(l==r) return ;
int mid=(l+r>>1);
binary_chop(l,mid);binary_chop(mid+1,r);
int p=l,q=l,j=mid+1;
while(p<=mid&&j<=r){
if(a[p]>a[j]){
k+=mid-p+1;//重点
b[q++]=a[j++];
}
else{
b[q++]=a[p++];
}
}
while(p<=mid) b[q++]=a[p++];
while(j<=r) b[q++]=a[j++];
for(int i=l;i<=r;i++) a[i]=b[i];
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",a+i);
}
binary_chop(1,n);
cout<<k<<endl;
return 0;
}