#include<stdio.h>

long n;
long A[200000];

/*void bubbleSort(){
  int i, j;
  int tmp;

  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(A[j] < A[j-1]){
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        count++;
      }
    }
  }
}*/
#define LIMIT 200000
#define INFTY 2000000000

long L[LIMIT/2+2], R[LIMIT/2+2];

long merge(long A[], long left, long mid, long right){
  long n1, n2, i, j, k;
  long count = 0;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY; R[n2] = INFTY;

  i = 0; j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
      count += n1 - i;
    }
  }
  return count;
}

long mergeSort(long A[], long left, long right){
  long mid;
  long cnt1, cnt2, cnt3;

  if(left+1 < right){
    mid = (left + right)/2;
    cnt1 = mergeSort(A, left, mid);
    cnt2 = mergeSort(A, mid, right);
    cnt3 = merge(A, left, mid, right);
    return cnt1+cnt2+cnt3;
  }else return 0;
}

int main(){
  long i, count;

  scanf("%ld", &n);
  for(i = 0; i < n; i++){
    scanf("%ld", &A[i]);
  }

  count = mergeSort(A, 0, n);

  printf("%ld\n", count);

  return 0;
}

