#include
#include
using namespace std;
const int N=1000;
int lowbit(int x){
return x&(-x);
}
void change(int *c,int position,int value,int len)
{
while(position<=len){
c[position]+=value;
position+=lowbit(position);
}
}
int sum(int *c,int n){
int answer=0;
while(n>0){
answer+=c[n];
n-=lowbit(n);
}
}
int main(){
int n;
int c[N];
int ans=0;
while(scanf("%d",&n)){
memset(c,0,sizeof©);
int x;
int answer=0;
for(int i=1;i<=n;i++){
scanf("%d",&x);
change(c,x,1,n);
ans+=i-sum(c,x);
}
printf("%d",ans);
}
}