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

int bubbleSort(unsigned long int A[], unsigned long int Num);



int main( void )
{
    unsigned long int num=0;
    unsigned long int i=0;
    unsigned long int cnt = 0;    // 反転数
    
    unsigned long A[200000] = {};
    
    scanf("%lu",&num);
    for(i=0; i<num; i++)
    {
        scanf("%lu", &A[i]);
    }
    
    cnt = bubbleSort(A, num);

    printf("%lu", cnt);
    
    return 0;
}

int bubbleSort(unsigned long int A[], unsigned long int Num)
{
    unsigned long int cnt = 0;    // 反転数
    unsigned long int i,j = 0;
    unsigned long int tmp = 0;
    
    
    for(i=0; i < Num; i++)
    {
        for(j=Num-1; j>i; j--)
        {
            if( A[j] < A[j-1] )
            {
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                
                cnt++;
            }
        }
    }
    return cnt;
}
