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

typedef struct _Node {
	int data;
	int count;
	struct _Node *left;
	struct _Node *right;
} Node;

static void setNode(Node *p, const int *data, Node *left, Node *right) {
	p->data = *data;
	p->count = 0;
	p->left = left;
	p->right = right;
}

Node *add(Node *p, const int *data, int *num) {
	int cmp;
	if (p == NULL) {
		p = (Node *)malloc(sizeof(Node));
		setNode(p,data,NULL,NULL);
	} else if ((cmp = *data - p->data) < 0) {
		*num += p->count + 1;
		p->left = add(p->left, data, num);
	}	else if (cmp > 0) {
		p->count++;
		p->right = add(p->right, data, num);
	}
	return p;
}

void terminate(Node *p) {
	if (p != NULL) {
		terminate(p->left);
		terminate(p->right);
		free(p);
	}
}

int main() {
	int n, i, data, numOfinv;
	Node *root = NULL;

	numOfinv = 0;
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%d",&data);
		root = add(root,&data,&numOfinv);
	}

	printf("%d\n",numOfinv);

	terminate(root);

	return 0;    
}