#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)
#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printd(x) printf("%.8f",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = n; i < m; i++)
#define allprintu(i,n,m,a) for(int i = n; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}

#define MAX 200000
#define LIMIT pow(10,9)+1
int n;
int a[MAX];

long long int merge(int A[],int n, int left, int mid, int right){
	long long int cnt = 0;
	int n1 = mid - left, n2 = right - mid;
	int *L = (int*)malloc(sizeof(int)*(n1+1));
	int *R = (int*)malloc(sizeof(int)*(n2+1));
	repu(i,0,n1){
		L[i] = A[left + i];
	}
	repu(i,0,n2){
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = LIMIT;
	int i = 0;
	int j = 0;
	repu(k,left,right){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i = i + 1;
		}else{
			A[k] = R[j];
			j = j + 1;
			cnt += n1 - i;
		}
	}
	free(L);
	free(R);
	return cnt;
}

long long int mergeSort(int A[], int n, int left, int right){
	long long int v1, v2, v3;
	if( left + 1 < right){
		int mid = (left+right)/2;
		v1 = mergeSort(A,n,left,mid);
		v2 = mergeSort(A,n,mid,right);
		v3 = merge(A,n,left, mid, right);
		return v1 + v2 + v3;
	}else{
		return 0;
	}
}
int main(void){
	scani(n);
	repu(i,0,n){
		scani(a[i]);
	}
	printf("%llu\n",mergeSort(a,n,0,n));
}

