#include <bits/stdc++.h>
using namespace std;
long long n,a[500005],c[500005],s;
void gb(int l,int r)
{
if(l==r) return ;
long long mid=(l+r)/2,p=l,q=mid+1,t=l;
gb(l,mid);
gb(mid+1,r);
while(p<=mid&&q<=r)
{
if(a[p]<=a[q]) c[t++]=a[p++];
else
{
c[t++]=a[q++];
s+=mid-p+1;
}
}
while(p<=mid) c[t++]=a[p++];
while(q<=r) c[t++]=a[q++];
for(int i=l;i<=r;i++) a[i]=c[i];
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
gb(1,n);
cout<<s;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
#define endl '\n'
#define lowbit(x) ((x)&-(x))
const int N=2e6+10;
typedef long long ll;
ll ans=0,n1,m1;
ll t=0,s1=0,s2=0,s3=0,s4=0,max1=0,max2=0,w,min1=100000000,sum=0,n,m,i,j,k=0;
inline int read() {
bool sym=0;
int res=0;
char ch=getchar();
while(!isdigit(ch))sym |=(ch =='-'),ch=getchar();
while(isdigit(ch)) res =(res<<3)+(res<<1)+(ch^48),ch=getchar();
return sym ? -res : res;
}
void print(int x) {
if(!x)return;
print(x/10);
putchar(x%10+'0');
}
int isPrime(int n) {
float n_sqrt;
if(n==1) return 0;
if(n==2 || n==3) return 1;
if(n%6!=1 && n%6!=5) return 0;
n_sqrt=floor(sqrt((float)n));
for(int i=5; i<=n_sqrt; i+=6) {
if(n%(i)==0 | n%(i+2)==0) return 0;
}
return 1;
}
ll treemax[200086],treemin[200006],tree[200063],b[510000];
void update(ll x) {
for(ll i=x; i<=n; i+=lowbit(i)) {
tree[i]++;
}
}
ll summ(ll x){
ll ans=0;
for(ll i=x;i>0;i-=lowbit(i))
ans+=tree[i];
return ans;
}
/*ll maxt(ll x, ll y) { //区间查询最大值
if(y > x) {
if(y - lowbit(y) > x) return max(treemax[y], maxt(x, y - lowbit(y) ) );
else return max(a[y], maxt(x, y - 1));
}
return a[x];
}
ll mint(ll x, ll y) { //区间查询最小值
if(y > x) {
if(y - lowbit(y) > x) return min(treemin[y], mint(x, y - lowbit(y)));
else return min(a[y], mint(x, y - 1));
}
return a[x];
}*/
struct node{
ll num,vv;
}a[500009];
ll cmp(node x,node y){
if(x.vv ==y.vv )
return x.num <y.num ;
return x.vv <y.vv ;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
//memset(treemin,0x3f3f3f3f,sizeof treemin);
cin>>n;
for(i=1; i<=n; i++) {
cin>>a[i].vv;
a[i].num=i;
//b[i]=a[i]-a[i-1];
}
sort(a+1,a+1+n,cmp);
for(i=1;i<=n;i++)
b[a[i].num ]=i;
for(i=1;i<=n;i++){
update(b[i]);
ans+=i-summ(b[i]);
}
cout<<ans;
return 0;
}
//mio lover