using namespace std;
#include <bits/stdc++.h>
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define maxN 60005
struct FenwickTree {
int y[maxN];
void add(int n, int i, int d) {
for(; i <= n; i += i&(-i)) y[i]+=d;
}
int sum(int j) {
int res = 0;
for(; j > 0; j -= j&(-j)) res+=y[j];
return res;
}
};
int n, m, a[maxN];
FenwickTree t;
ll ans;
int main () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
scanf("%d", &n);
fto(i, 1, n) scanf("%d", &a[i]);
fdto(i, n, 1) {
ans+=t.sum(a[i]-1);
t.add(n, a[i], 1);
}
cout << ans;
return 0;
}
dXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbWFwaWkgbWFwPGludCwgaW50PgojZGVmaW5lIGRlYnVnKGEpIGNvdXQgPDwgI2EgPDwgIjogIiA8PCBhIDw8IGVuZGwKI2RlZmluZSBmZHRvKGksIHIsIGwpIGZvcihpbnQgaSA9IHI7IGkgPj0gbDsgLS1pKQojZGVmaW5lIGZ0byhpLCBsLCByKSBmb3IoaW50IGkgPSBsOyBpIDw9IHI7ICsraSkKI2RlZmluZSBmb3JpdChpdCwgdHlwZSwgdmFyKSBmb3IodHlwZTo6aXRlcmF0b3IgaXQgPSB2YXIuYmVnaW4oKTsgaXQgIT0gdmFyLmVuZCgpOyBpdCsrKQojZGVmaW5lIGlpIHBhaXI8aW50LCBpbnQ+CiNkZWZpbmUgaWlpIHBhaXI8aW50LCBpaT4KI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlI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