n=gets.to_i
s=gets.split.map &:to_i
c=0
M=->l,m,r{o=m-l
p=r-m
w=s[l,o]
e=s[m,p]
w<<1e10
e<<1e10
i=j=0
(l...r).map{|k|if w[i]<=e[j]
s[k]=w[i]
i+=1
else
s[k]=e[j]
j+=1
c+=o-i
end}}
S=->f,l,r{if l+1<r
m=(l+r)/2
f[f,l,m]
f[f,m,r]
M[l,m,r]
end}
S[S,0,n]
p c