#include<bits/stdc++.h>
#ifdef WIN32
#define outl "%I64d"
#else
#define outl "%lld"
#endif
using namespace std;
typedef long long LL;
const int MAXN = 1000005;
int n, a[MAXN], c[MAXN];
LL ans;
int low_bit(int x){
return x & -x;
}
void insert(int x){
while(x < 1000000){
c[x]++;
x += low_bit(x);
}
}
LL query(int x){
LL res = 0;
while(x){
res += c[x];
x -= low_bit(x);
}
return res;
}
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for(int i = n; i >= 1; i--){
ans += query(a[i]);
insert(a[i]+1);
}
printf(outl, ans);
return 0;
}