#include<stdio.h>
#define MAX 20000

int main() {
	int N;
	int A[MAX];
	long long cnt = 0;
	int sp, buff;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < N; i++) {
		sp = i;
		buff = A[i];
		while (sp != 0 && A[sp - 1] > buff) {
			A[sp] = A[sp - 1];
			sp--;
			cnt++;
		}
		A[sp] = buff;
	}

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

	return 0;
}

