include[HTML_REMOVED]
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
int n;
int a[N], temp[N];
ll ans = 0;
void merge_sort(int q[], int l, int r)
{
if (l >= r)return;
int mid = l + r >> 1;
merge_sort(q, l, mid);
merge_sort(q, mid + 1, r);
int i = l, j = mid + 1;
int k = 0;
while (i <= mid && j <= r)
{
if (q[i] <= q[j])temp[k++] = q[i++];
else
{
temp[k++] = q[j++];
ans += (mid - i + 1);
}
}
while (i <= mid)temp[k++] = q[i++];
while (j <= r)temp[k++] = q[j++];
for (int i = l, j = 0; i <= r; i++, j++)
q[i] = temp[j];
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)cin >> a[i];
merge_sort(a, 0, n - 1);
cout << ans << endl;
return 0;
}