#include <stdio.h>
#define MAX 200000
#define INFTY 2000000000
void Merge(int[MAX],int,int,int);
void MergeSort(int[MAX],int,int);
long long cnt = 0;

int main()
{
    int i, n;
    int A[MAX];
  
    scanf("%d", &n);
    for(i =0; i < n; i++)
        scanf("%d", &A[i]);
    MergeSort(A, 0, n);
    printf("%lld\n",cnt);
    return 0;
}
 
void Merge(int A[MAX], int left, int mid, int right)
{
  int i,j,k;
  int na,nb;
  
  na = mid - left;
  nb = right - mid; 
  int L[MAX], R[MAX];
  for(i = 0; i < na; i++)
    L[i] = A[left + i];
  for(i = 0; i < nb; i++)
    R[i] = A[mid + i];
  L[na] = INFTY; R[nb] = INFTY;
  i = 0;j = 0;
  for(k = left; k < right; k++)
  {
    if(L[i] <= R[j])
      A[k] = L[i++];
    else
    {
      A[k] = R[j++];
      cnt += na - i;
    }
  }
  
}
  
void MergeSort(int A[MAX], int left, int right)
{
  
  int mid;
  if((left + 1) < right)
  { 
    mid = (left + right) / 2; 
    MergeSort(A, left, mid);
    MergeSort(A, mid, right); 
    Merge(A, left, mid, right);
  
  }
  
}
