#include<stdio.h>

int A[200100];
int L[200100 / 2], R[200100 / 2];

long long merge(long long left, long long mid, long long right)
{
	long n1, n2;
	long long cnt = 0;
	n1 = mid - left;
	n2 = right - mid;
	for (long long i = 0; i < n1; i++) L[i] = A[left + i];
	for (long long i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = 0x7fffffff;
	for (long long k = left, j = 0, i = 0; k < right; k++)
	{
		if (L[i] <= R[j])
			A[k] = L[i++];
		else
		{
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

long long mergeSort(int left, int right)
{
	long long v1, v2, v3, mid;
	if (left + 1 < right)
	{
		mid = (left + right) / 2;
		v1 = mergeSort(left, mid);
		v2 = mergeSort(mid, right);
		v3 = merge(left, mid, right);
		return v1 + v2 + v3;
	}
	return 0;
}

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