#include <bits/stdc++.h>
using namespace std;
int seq[210000], temp[210000];
int64_t msort(int l, int r) {
  if (l == r - 1) return 0LL;
  int mid = (l + r) >> 1;
  int64_t anti = msort(l, mid) + msort(mid, r);
  int i = l, j = mid, k = l;
  while (k < r) {
    while (k < r && (j == r || (i < mid && seq[i] <= seq[j])))
      temp[k++] = seq[i++];
    while (k < r && (i == mid || (j < r && seq[j] < seq[i]))) {
      temp[k++] = seq[j++];
      anti += mid - i;
    }
  }
  memcpy(seq + l, temp + l, (r - l) * sizeof(int));
  return anti;
}
void Conduct(const int &length) {
  for (int i = 0; i < length; ++i) scanf("%d", &seq[i]);
  int64_t anti = msort(0, length);
  cout << anti << endl;
}
int main() {
  int length;
  while (scanf("%d", &length) != EOF) Conduct(length);
  return 0;
}
