#include<stdio.h>
#include<string.h>
#include<limits.h>

#define n_max 200000


long merge(int A[],int left,int mid,int right);
long mergeSort(int A[],int left,int right);
int main(void){
	int n,i;
	int a[n_max];
	int ans;
	long cnt;
	
	scanf("%d", &n);
	for(i = 0;i<n;i++){
		scanf("%d", &a[i]);
	}
	
	cnt = mergeSort(a, 0, n);
	printf("%ld\n", cnt);
	return 0;
	
}


long merge(int A[],int left,int mid,int right){
  	int n1 = mid - left;
  	int n2 = right - mid;
	int R[n1+1], L[n2+1];
	int i, j, k;
	long cnt=0;
  //L[0...n1], R[0...n2] を生成
	for (i = 0;i <n1;i++){
		L[i] = A[left + i];
	}
	for (i = 0;i <n2;i++){
		R[i] = A[mid + i];
	}
 	L[n1] = INT_MAX;
  	R[n2] = INT_MAX;
	i = 0;
	j = 0;
	for (k = left ;k<right;k++){
		if( L[i] <= R[j]){
	      A[k] = L[i];
	      i = i + 1;
		  
		}
		else {
	      A[k] = R[j];
	      j = j + 1;
			cnt +=n1 - i ;
		}
	}
	return cnt;
}
long mergeSort(int A[],int left,int right){
	long cnt1 = 0, cnt2 = 0, cnt3 = 0;
	if( left+1 < right){
    int mid = (left + right)/2;
    cnt1 = mergeSort(A, left, mid);
    cnt2 = mergeSort(A, mid, right);
    cnt3 = merge(A, left, mid, right);
	}
	return cnt1+cnt2+cnt3;
}
