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


int main(){

    long i, j, t;
    long c=0;
    long n;
    long *A;

    scanf( "%ld", &n);

    A = (long*)malloc(sizeof(long)*n);
    
    for( i=0; i<n; i++) scanf( "%ld", &A[i] );


    //
    for( i=1; i<n; i++ ){
        t = A[i];
        if( A[i-1] > t ){
            j=i;
            do{
                A[j] = A[j-1];
                j--;
                c++;
            }while( j>0 && A[j-1]>t );
            A[j]=t;
        }
    }


    printf( "%ld\n", c);

    free(A);

    return 0;
}

