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

#define MaxNum 200000

int main( void )
{
    unsigned long int num=0;
    unsigned long int i,j=0;
    unsigned long int cnt = 0;    // 反転数
    unsigned long int tmp = 0;
    unsigned long int case2=0;
    unsigned long int case3=0;
    unsigned long int case4=0;
    unsigned char   B[MaxNum] = {};
    
    scanf("%lu",&num);
    if(num == 0)
    {
        printf("0\n");
        return 0;
    }
    
    for(i=0; i<num; i++)
    {
        scanf("%lu", &tmp);
        B[tmp]=1;
        j=tmp/50000;
        
        switch (j){
            case 0:
                for(j=tmp+1;j<=50000;j++)
                {
                    cnt=cnt+B[j];
                }
                cnt=cnt+case2+case3+case4;
                break;
                
            case 1:
                case2++;
                for(j=tmp+1;j<=100000;j++)
                {
                    cnt=cnt+B[j];
                }
                cnt=cnt+case3+case4;
                break;
            

            case 2:
                case3++;
                for(j=tmp+1;j<=150000;j++)
                {
                    cnt=cnt+B[j];
                }
                cnt=cnt+case4;
                break;
            
            
            case 3:
                case3++;
                for(j=tmp+1;j<=200000;j++)
                {
                    cnt=cnt+B[j];
                }
                break;
                
            default:
            ;
        }
    }
    
    printf("%lu\n", cnt);
    
    return 0;
}


