#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=40010;
int n,ans,a[maxn],b[maxn],c[maxn],s[maxn];
int lowbit(int x)
{
return x&(-x);
}
void add(int x)
{
for(int i=x;i<=n;i+=lowbit(i))
c[i]++;
}
int getsum(int x)
{
int ans=0;
for(int i=x;i>=1;i-=lowbit(i))
ans+=c[i];
return ans;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i],s[i]=a[i];
sort(s+1,s+n+1);
int tot=unique(s+1,s+n+1)-s-1;
for(int i=1;i<=n;i++)
{
int pos=lower_bound(s+1,s+tot+1,a[i])-s;
b[i]=pos;
}
for(int i=n;i>=1;i--)
{
ans+=getsum(b[i]);
add(b[i]+1);
}
cout<<ans;
return 0;
}