n=int(input())
list=[]
for b in range(n):
    a=int(input())
    list.append(a)
c=int(0)    
for i in range(n):
    b=len(list)-c
    for j in range(n-b-1):
        if list[j]<list[j+1]:
            list[j],list[j+1]=list[j+1],list[j]
            c+=int(1)
        else:                                  
            c=c+int(1)
print(c)