1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<algorithm>
5 using namespace std;
6 int n,m,a[100010]={0},b[100010];
7 long long ans=0;
8 void ni(int l,int r)
9 {
10 if(l==r) return;
11 int mid=(l+r)/2;
12 ni(l,mid);ni(mid+1,r);
13 int i=l,j=mid+1,k=l;
14 while(i<=mid&&j<=r)
15 {
16 if(a[i]>a[j])
17 {
18 b[k++]=a[j++];
19 ans+=mid-i+1;
20 }
21 else{
22 b[k++]=a[i++];
23 }
24 }
25 while(i<=mid) b[k++]=a[i++];
26 while(j<=r) b[k++]=a[j++];
27 for(int w=l;w<=r;w++) a[w]=b[w];
28 }
29 int main()
30 {
31 scanf("%d",&n);
32 for(int i=1;i<=n;i++)
33 { scanf("%d",&a[i]); }
34 ni(1,n);
35 printf("%lld",ans);
36 return 0;
37 }