#include <stdio.h>

typedef struct _element{
	int i, val;
} element;

int element_sort(void * a ,void * b ) {
	return (*(element*)a).val - (*(element*)b).val;
}

/*
int bubbleSort(int A[], int n) {
	int i, j, t, s;
	int cnt = 0; // 反転数
	for(i=0;i<n-1;i++) {
		for(j=n-1,s=i+1;j>=s;j--) {
	    	if(A[j] < A[j-1]) {
	    		t = A[j];
	    		A[j] = A[j-1];
	    		A[j-1] = A[j];
				cnt++;
	    	}
		}
	}
  
	return cnt;
}
*/

int reverse_count(element A[], int n) {
	int i, cnt;
	for(i=0;i<n;i++) {
		if(A[i].i > i) {
			cnt += (A[i] - i);
		}
	}
	return cnt;
}

int main(void) {
	element A[200005];
	int i, n;
	scanf("%d\n", &n);
	
	for(i=0;i<n;i++) {
		A[i].i = i;
		scanf("%d", &A[i].val);
	}
	
	qsort((void*)A, n, sizeof(element), element_sort);
	
	printf("%d\n", reverse_count(A, n));
	
	return 0;
}