n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
n=0
a=0
b=1
while b-1<=len(l):
    if l[a]>l[b]:
          d=l[a]
          l[a]=l[b]
          l[b]=d
          n+=2
    a+=1
    b+=1
    if l==sorted(l):
       break
print(n)