n=gets.to_i
s=gets.split.map &:to_i
c=0
M=->l,m,r{n1=m-l
n2=r-m
ll=s[l,n1]
rr=s[m,n2]
ll<<1e10
rr<<1e10
i=j=0
(l...r).map{|k|if ll[i]<=rr[j]
s[k]=ll[i]
i+=1
else
s[k]=rr[j]
j+=1
c+=n1-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