#include<cstdio>
using namespace std;
int n,a[100001],b[100001];
unsigned long long int ans=0;
void nxd(int l,int r)
{
if(l==r) return ;
int mid=(l+r)/2;
nxd(l,mid),nxd(mid+1,r);
int lik=l,rik=mid+1,now=l-1;
while(now<r)
{
if(lik<=mid&&rik<=r)
{
if(a[lik]<=a[rik])
{
b[++now]=a[lik++];
ans+=rik-mid-1;
}
else b[++now]=a[rik++];
}
else
{
if(lik<=mid)
{
b[++now]=a[lik++];
ans+=rik-mid-1;
}
else
{
b[++now]=a[rik++];
}
}
}
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]);
nxd(1,n);
printf("%lld\n",ans);
return 0;
}