#include <stdio.h>          // printf(), scanf()
#include <ctype.h>          // isdigit()
#define MAX_N 200000

int bit[MAX_N + 1];
int n;

int
sum(int i)
{
	int s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}

	return s;
}

void
add(int i, int x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

int
main(int argc, char** argv)
{
	int a;
	int i;
	int c;

	for (i = 0; i <= n; ++i)
		bit[i] = 0;

	c = getc(stdin);
	n = 0;
	while (isdigit(c))
	{
		n = n * 10 + c - '0';
		c = getc(stdin);
	}

	long ans = 0;
	for (i = 0; i < n; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		a = 0;
		while (isdigit(c))
		{
			a = a * 10 + c - '0';
			c = getc(stdin);
		}

		ans += i - sum(a);
		add(a, 1);
	}

	printf("%ld\n", ans);
	return 0;
}