include[HTML_REMOVED]
using namespace std;
int a[1000010], b[1000010], n;
long long cc;
long long paixu(int l, int r)
{
if (l >= r)return 0;
int mid = l + r >> 1;
cc=paixu(l, mid)+paixu(mid + 1, r);
int w = 0, i = l, j = mid + 1;
while (i <= mid && j <= r)
if (a[i] > a[j]) {b[w] = a[j]; cc += mid - i + 1;}
else b[w] = a[i];
while (i <= mid)b[w] = a[i];
while (j <= r)b[w] = a[j];
for (int i = l, j = 0; i <= r; i, j)
a[i] = b[j];
return cc;
}
int main()
{
cin >> n;
for (int i = 0; i < n; i++)cin >> a[i];
cout<<paixu(0, n - 1);
return 0;
}