#include <iostream>
using namespace std;
#define N 100010
typedef long long LL;
int arr[N];
int tmp[N];
LL merge_sort(int arr[],int l,int r) {
if (l >= r) {
return 0;
}
int mid = r + l >> 1;
int k = 0; int i = l; int j = mid + 1;
LL sum = 0;
sum += merge_sort(arr, l, mid) + merge_sort(arr, mid + 1, r);
while (i <= mid && j <= r) {
if (arr[i] <= arr[j])tmp[k++] = arr[i++];
else {
sum += mid - i + 1;
tmp[k++] = arr[j++];
}
}
while(i <= mid)tmp[k++] = arr[i++];
while(j <= r)tmp[k++] = arr[j++];
for (i = l, j = 0; i <= r; i++, j++)arr[i] = tmp[j];
return sum;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cout << merge_sort(arr,0,n-1) << endl;
system("pause");
return 0;
}