#include <stdio.h>
#include <string.h>

int InSort(int A[], int n)
{
  int sum=0;
    for (int i = 1; i < n; i++)         
    {
        int temp = A[i];                 
        int j = i - 1;                  
        while (j >= 0 && A[j] > temp)    
        {
            A[j + 1] = A[j];sum++;          
            j--;                        /////////   J 位置理解!!!!!!!!!!!!!!!!!!!!! 
        }
        A[j + 1] = temp; // fang jin qu
    }
    return sum;
}
int main ()
{
	int a[200010];
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	scanf("%d",&a[i]);
	printf("%d\n",InSort(a,t));
	return 0;
} 