#include <bits/stdc++.h>
using namespace std;
int Lowbit(int x) { return x & (-x); }
struct zz {
  int id, z;
} a[100005];
int lsh[100005], bit[100005], n;
bool cmp(zz x, zz y) { return x.z < y.z; }
void HHup(int x, int k) {
  for (int i = x; i <= n; i += Lowbit(i)) bit[i] += k;
}
long long HHsum(int x1) {
  long long ans = 0;
  for (int i = x1; i >= 1; i -= Lowbit(i)) {
    ans += bit[i];
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].z);
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  int len = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].z == a[i - 1].z) {
      lsh[a[i].id] = len;
    } else {
      lsh[a[i].id] = ++len;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    HHup(lsh[i], 1);
    ans += i - HHsum(lsh[i]);
  }
  printf("%lld", ans);
  return 0;
}
