#include <stdio.h>

long n;
long a[200000];
long b[200000];
long long count = 0;

void partinversion(long begin, long last) {
	long mid = (begin + last) / 2;
	if (mid - begin > 0) {
		partinversion(begin, mid);
	}
	if (last - mid > 1) {
		partinversion(mid, last);
	}
	long p = begin, q = mid;
	long k = begin;
	while (p < mid && q < last) {
		if (a[p] <= a[q]) {
			b[k] = a[p];
			p++;
			k++;
		}
		else {
			b[k] = a[q];
			q++;
			k++;
			count += mid-p;
		}
	}
	while (p < mid) {
		b[k] = a[p];
		p++;
		k++;
	}
	while (q < last) {
		b[k] = a[q];
		q++;
		k++;
	}
	for (long j = begin; j < last; ++j) {
		a[j] = b[j];
	}
}

int main() {
	scanf("%ld", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%ld", &a[i]);
	}
	partinversion(0, n);
	printf("%ld\n", count);
	return 0;
}
