/*
	The Number of Inversions
*/

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


int *WORK;
long long int COMPARE_COUNT;


void Merge_sort(int *S, int low, int high)
{
	int mid;
	int i, j, k;


	if(high <= low)
		return;

	mid = (low + high) / 2;

	// 左側の処理
	Merge_sort(S, low, mid);

	// 右側の処理
	Merge_sort(S, mid + 1, high);

	for(i = low; i <= mid; i++)
		WORK[i] = S[i];

	for(i = high, j = mid + 1; i > mid; i--, j++)
		WORK[i] = S[j];


	// マージ
	i = low;
	j = high;
	for(k = low; k <= high; k++){
		if(WORK[i] <= WORK[j]){
			S[k] = WORK[i++];
		}else{
			S[k] = WORK[j--];
			//COMPARE_COUNT += ((mid - low + 1) - (i - low));
			COMPARE_COUNT += mid - i + 1;	// 上の式を変形
		}
	}
}


int main()
{
	int n;
	int n2;
	int *box;
	int i;


	scanf("%d", &n);
	n2 = n;

	box = (int *)malloc(sizeof(int) * n);
	WORK = (int *)malloc(sizeof(int) * n);

	srand((unsigned)time(NULL));
	for(i = 0; i < n; i++)
		scanf("%d", &box[i]);

	COMPARE_COUNT = 0;
	Merge_sort(box, 0, n - 1);

	printf("%lld\n", COMPARE_COUNT);

	return 0;
}
