#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

#define MAX 200000 //数列の長さn
#define AI 1000000001

long long cnt;

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



void merge (long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long L[AI] = {0}, R[AI] = {0};
  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] = MAX;
  R[n2] = MAX;
  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);
    }
  }
}


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

