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

#define INFTY 2000000009
#define N 100000005
int count = 0;
int A[N];

int merge(int A[],int left,int mid, int right){
int i,j,k,n1,n2,*L,*R;
int mcount=0;
n1 = mid - left;
n2 = right - mid;
L = (int *)malloc((n1+1) * sizeof(int));
R = (int *)malloc((n2+1) * sizeof(int));
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;
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;
mcount += n1 - i;
}
}
free(L);
free(R);
return mcount;
}


int mergeSort(int A[],int left,int right){
int mid,a,b,c;
if(left+1 < right){
mid = (left + right) / 2;
a = mergeSort(A,left,mid);
b = mergeSort(A,mid,right);
c = merge(A,left,mid,right);
return a+b+c;
}
else return 0;
}

int main(){
int i,n;
int answer;

scanf("%d",&n);
for(i=0; i<n; i++) scanf("%d",&A[i]);
answer = mergeSort(A,0,n);

printf("%d\n",answer);

return 0;

}