#include<stdio.h>
#define SEN 2000000000
#define MAX 200000

long long merge(int a[], int n, int left, int mid, int right)
{
	int i, j, k;
	long long c = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	
	int l[MAX/2+2], r[MAX/2+2];
	
	for( i = 0; i < n1; i++ ){
		l[i] = a[left+i];
	}
	for( i = 0; i < n2; i++ ){
		r[i] = a[mid+i];
	}
	
	l[n1] = SEN;
	r[n2] = SEN;
	
	i = j = 0;
	
	for( k = left; k < right; k++ ){
		if( l[i] <= r[j] ){
			a[k] = l[i];
			i++;
		}else{
			a[k] = r[j];
			j++;
			c += n1 - i;
		}
	}
	return c;
}

long long mergeSort(int a[], int n, int left, int right)
{
	int mid;
	long long x, y, z;
	if( left+1 < right ){
		mid = (left+right) / 2;
		x = mergeSort(a, n, left, mid);
		y = mergeSort(a, n, mid, right);
		z = merge(a, n, left, mid, right);
		return x+y+z;
	}else{
		return 0;
	}
}

int main(){
	int n, i;
	long long c;
	scanf( "%d", &n );
	
	int a[n];
	for( i = 0; i < n; i++ ){
		scanf( "%d", &a[i] );
	}
	
	c = mergeSort(a, n, 0, n);
	printf( "%lld\n", c );
	
	return 0;
}
	
