#include <stdio.h>
#define INFTY 2000000000
#define MAX 500000


int L[MAX/2+2];
int R[MAX/2+2];
long mergesort(int A[], int left,int right);
long merge(int A[], int left,int mid,int right);

int main(void){
	int A[MAX];
	int n,i;
	long cnt = 0;
	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;
	long cnt = 0;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
	
		R[i]=A[mid+i];
	}
	
	L[n1]=R[n2]=INFTY;
	int i=0,j=0;
	
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}
		else{
			A[k]=R[j];
			j++;
			cnt+=n1-i;
		}
	}
	return cnt;
}

long mergesort(int A[],int left,int right){
	long c1=0,c2=0,c3=0;
	if(left+1<right){
		int mid=(left+right)/2;
		c1=mergesort(A,left,mid);
		c2=mergesort(A,mid,right);
		c3=merge(A,left,mid,right);
	}
	return c1+c2+c3;
}


