#include <stdio.h>
#include <stdlib.h>
#define INF 1000000001

void merge(int, int, int);
void mergeSort(int, int);

int n;
int A[200000];
int L[100001], R[100001];
long cnt = 0;
	
int main()
{
	int i;
	int n;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}
	
	mergeSort(0, n);

	printf("%ld\n", cnt);
	
	return 0;
}

void mergeSort(int left, int right)
{
	int mid;

  	if(left + 1 < right)
    {
     	mid = (left + right)/2;
     	mergeSort(left, mid);
     	mergeSort(mid, right);
   		merge(left, mid, right);
    }
}

void merge(int left, int mid, int right)
{
  	int i, j, k;
	int n1, n2;
 
	n1 = mid - left;
 	for(i = 0; i < n1; i++)
    {
    	L[i] = A[left + i];
    }
  	L[n1] = INF;
  
  	n2 = right - mid;
  	for(j = 0; j < n2; j++)
    {
      	R[j] = A[mid + j];
    }
  	R[n2] = INF;

	i = 0;
	j = 0;
  	for(k = left; k < right; k++)
  	{
      	if(L[i] <= R[j])
	    {
	    	A[k] = L[i];
	    	i++;
	    }
      	else
	  	{
	  		A[k] = R[j];
	    	cnt += n1 - i;
	    	j++;
	  	}
	}
}