#include <bits/stdc++.h>
using namespace std;
int a[500001], temp[500001], n;
long long ans = 0;
void sort(int l, int r) {
  if (l == r) return;
  int mid = (l + r) / 2;
  sort(l, mid);
  sort(mid + 1, r);
  int i = l, j = mid + 1, p = l;
  while (i <= mid && j <= r) {
    if (a[i] > a[j]) {
      ans += mid - i + 1;
      temp[p++] = a[j++];
    } else {
      temp[p++] = a[i++];
    }
  }
  while (i <= mid) temp[p++] = a[i++];
  while (j <= r) temp[p++] = a[j++];
  for (int i = l; i <= r; i++) a[i] = temp[i];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(1, n);
  cout << ans;
}
