#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
int n;
int q[N], tmp[N];
LL merge(int l, int r){
if (l >= r) return 0;
int mid = l + r >> 1;
LL res = merge(l, mid) + merge(mid + 1, r);
int k = 0, i = l, j = mid + 1;
while(i <= mid && j <= r) {
if (q[i] <= q[j]) tmp[k++] = q[i ++];
else {
tmp[k ++] = q[j ++];
res += mid - i + 1;
//这步是关键 每一次递归都可以计算当前范围的逆序对数 然后改变一个范围内的数字顺序不影响两个范围的逆序对数
//q[i] 如果大于q[j]那q[i]后面的数字都大于q[j]所以 加mid - i + 1;
}
}
while(i <= mid) tmp[k++] = q[i++];
while(j <= r) tmp[k++] = q[j++];
for(int k = 0, i = l; i <= r; k++, i++) q[i] = tmp[k];
return res;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++){
cin >> q[i];
}
cout << merge(0, n - 1);
return 0;
}