#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
 
#define MAX 200000
#define M 1000000001
 
long long cnt;
 
int merge (int A[], int left, int mid, int right){
  int n1, n2, i, j, k;
  int L[MAX / 2 + 2], R[MAX / 2 + 2];
  n1 = mid - left;
  n2 = right - mid;
  // L=n1+1;
  // R=n2+1;
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  L[n1] = M;
  R[n2] = M;
  i = 0;
  j = 0;
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
      cnt += (n1 - i);
    }
  }
  return 0;
}

int mergeSort(int A[], int left , int right ) {
    int i, mid;
    if(left + 1 < right) {
        mid = (right + left) / 2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
    return 0;
}


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