#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

void merge(int *A,int left,int mid,int right,int *swap){
	int n1,n2,i,j,k;
	int *L,*R;
	n1=mid-left;
	n2=right-mid;
	mymalloc(L,n1+1);
	mymalloc(R,n2+1);
	for(i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(j=0;j<n2;j++){
		R[j]=A[mid+j];
	}
	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++;
		}
		else{
			A[k]=R[j];
			j++;
			*swap+=n1-i;
		}
	}
	free(L);free(R);
}

void mergeSort(int *A,int left,int right,int *swap){
	int mid;
	if(left+1<right){
		mid=(right-left)/2+left;
		mergeSort(A,left,mid,swap);
		mergeSort(A,mid,right,swap);
		merge(A,left,mid,right,swap);
	}
}

main(){
	int i,j,swap,n;
	int *A;
	scanf("%d",&n);
	mymalloc(A,n);
	for(i=0;i<n;i++){
		scanf(" %d",&(A[i]));
	}
	swap=0;
	mergeSort(A,0,n,&swap);
	printf("%d\n",swap);
	free(A);
	return 0;
}