#include <bits/stdc++.h>
using namespace std;
int n, a[100005], t[100005];
long long ans = 0;
void gb_sort(int l, int r)
{
if (l >= r)
return;
int mid = l + r >> 1;
gb_sort(l, mid);
gb_sort(mid + 1, r);
int i = l, nl = l, ml = mid + 1;
while (nl <= mid && ml <= r)
if (a[nl] > a[ml])
{
ans += mid - nl + 1;
t[i++] = a[ml++];
}
else
t[i++] = a[nl++];
while (nl <= mid)
t[i++] = a[nl++];
while (ml <= r)
t[i++] = a[ml++];
for (i = l; i <= r; i++)
a[i] = t[i];
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
scanf("%d", a + i);
gb_sort(1, n);
cout << ans;
return 0;
}