#include <stdio.h>
#define MAX 200000
#define SENTINEL 2000000000
long long merge(int*,int,int,int);
long long mergeSort(int*,int,int);

int L[MAX/2 + 2],R[MAX/2 + 2];

int main(){
  int n,i;
  int A[MAX];
  long long result;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  result = mergeSort(A,0,n);
  printf("%d\n",result);
  return 0;
}

long long merge(int* A,int left,int mid,int right){
  long long count = 0;
  int i,j,k;
  int n1,n2;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(j = 0; j < n2; j++) R[j] = A[mid + j];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
      count += n1 - i;
    }
  }
  return count;
}

long long mergeSort(int* A, int left, int right){
  int mid;
  long long a1,a2,a3;
  if(left+1 < right){
    mid = (left + right)/2;
    a1 = mergeSort(A,left,mid);
    a2 = mergeSort(A,mid,right);
    a3 = merge(A,left,mid,right);
    return a1+a2+a3;
  }
  else return 0;
}