#include <stdio.h>
#include <stdlib.h>
#define N 200000

unsigned int a[N];

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

int merge_sort(int *a, int l, int r){
int m  = (l+r)/2, count, i, j;
int n1, n2, v1, v2, cnt = 0;
  if(l == r)
   return 0;

  v1 = merge_sort(a, l, m);
  v2 = merge_sort(a, m + 1, r);
  n1 = m-l+1;
  n2 = r - m;
  L[n1]  = R[n2] = 200000000;
  for(count = l; count <= m; count++){
     L[count - l] = a[count];
  }
  for(count = m + 1; count <= r; count++){
    R[count - m - 1] = a[count];
  }
  for(i = 0, j = 0, count = l; count <= r; count++){
    if(L[i] <= R[j]){
     a[count] = L[i++];
    }
    else{
     a[count] = R[j++];
     cnt += n1 - i;
    }

  }

   return cnt + v1 + v2;
}

int main(int argc, char** argv){
int n, i = 0;
   scanf("%d", &n);

   for(i; i < n; i++)
    scanf("%d", &a[i]);


 printf("%d\n", merge_sort(a, 0, n-1));

  return 0;
}