#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define int long long
 
#define iin(x) scanf("%d", &x)
#define lin(x) scanf("%lld", &x)
#define fin(x) scanf("%lf", &x)
 
#define iout(x) printf("%d", x)
#define lout(x) printf("%lld", x)
#define fout(x) printf("%.10f", x)
#define _ putchar(' ')
#define endl puts("")
 
#define reps(i, x, n) for(i = (x); i < (n); i++)
#define rep(i, n) reps(i, 0, n)
 
int L[500001], R[500001];
 
int merge(int A[], int left, int mid, int right) {
  int res = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  int i, j, k;
  rep(i, n1) L[i] = A[left+i];
  rep(i, n2) R[i] = A[mid+i];
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  i = 0, j = 0;
  reps(k, left, right) {
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
      res += n1 - i;
    }
  }
  return res;
}
 
int mergeSort(int A[], int left, int right) {
  int a = 0, b = 0, c = 0;
  if(left + 1 < right) {
    int mid = (left + right) / 2;
    a = mergeSort(A, left, mid);
    b = mergeSort(A, mid, right);
    c = merge(A, left, mid, right);
  }
  return a+b+c;
}
 
int A[500001];
 
signed main() {
  int n; lin(n);
  int i;
  rep(i, n) lin(A[i]);
  lout(mergeSort(A, 0, n)),endl;
 
  return 0;