#include<stdio.h>
#define N 2000000
#define INFTY 1000000001


void mergesort(int A[], int left, int right);
void merge(int A[], int left, int mid, int right);

long count=0;

int main(void){
	int n;
	scanf("%d", &n);
	
//	int A[n], i;
	int A[N], i;
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	
	mergesort(A, 0, n);

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


void merge(int A[], int left, int mid, int right){
	int n1, n2;
	
	n1 = mid - left;//左配列の長さ
	n2 = right - mid;//右配列の長さ

	/*L[0...n1], R[0...n2] を生成*/
//	int L[n1+1], R[n2+1];
	int L[N], R[N];

	int i;
	for(i = 0; i<n1; i++) {
		L[i] = A[left + i];//生成
	}
	for(i = 0; i<n2; i++) {
		R[i] = A[mid + i];//生成
	}
	L[n1]=INFTY;
	R[n2]=INFTY;

	int j, k;
	i=0;
	j=0;
	for(k=left; k<right; k++){//全体回数
		if(n1==i){
			A[k]=R[j];
			j++;
			count+=(n1-i);
		}
		else if(n2==j){
			A[k]=L[i];
			i++;
		//	count[0]++;
		}
		else if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
		//	count[0]++;
		}
		else if(R[j] <= L[i]){
			A[k] = R[j];
			j++;
			count+=(n1-i);
		}
	}
}

void mergesort(int A[], int left, int right) {
	int mid;
	if(2<=right-left){
		mid=(left+right)/2;
		mergesort(A, left, mid);//分ける
		mergesort(A, mid, right);
		merge(A, left, mid, right);
	}
}

