#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

#define INFTY 2000000000
#define N 2000005
typedef unsigned long long llong;
int A[N];
int L[N/2+1],R[N/2+1];

llong merge(int left,int mid, int right){
  int i,j,k,n1,n2;
  llong mcount=0;
  n1 = mid - left;
  n2 = right - mid;
  /* L = (int *)malloc((n1+1) * sizeof(int));
     R = (int *)malloc((n2+1) * sizeof(int));*/
  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 = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
      mcount += n1 - i;
    }
  }
  return mcount;
}


llong mergeSort(int left,int right){
  int mid;
  llong a,b,c;
  if(left+1 < right){
    mid = (left + right) / 2;
    a = mergeSort(left,mid);
    b = mergeSort(mid,right);
    c = merge(left,mid,right);
    return a+b+c;
  }
  else return 0;
}

int main(){
  int i,n;
  llong answer;

  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  answer = mergeSort(0,n);

  printf("%d\n",answer);

  return 0;

}