#include <algorithm>
#include <cstdio>
using std::stable_sort;
int n, c[500005], lsh[500005], a[500005];
long long ans, sum;
int lowbit(int x)
{
return x & (-x);
}
void add(int x)
{
while (x <= n)
c[x]++, x += lowbit(x);
}
int query(int x)
{
sum = 0;
while (x > 0)
sum += c[x], x -= lowbit(x);
return sum;
}
bool cmp(int x, int y)
{
return a[x] > a[y];
}
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
lsh[i] = i;
}
stable_sort(lsh + 1, lsh + n + 1, cmp);
for (int i = 1; i <= n; i++)
{
add(lsh[i]);
ans += query(lsh[i] - 1);
}
printf("%lld", ans);
return 0;
}