#include<stdio.h>

#define MAX 200000

int BubbleSort(int *A,int n){
  int cont=0;
  int flag=1;
  int i,tmp;
  while(flag==1){
    flag=0;
    for(i=n-1;i>=1;i--){
      if(A[i]<A[i-1]){
	tmp=A[i];
	A[i]=A[i-1];
	A[i-1]=tmp;
	flag=1;
	cont++;
      }
    }
  }
  return cont;
}
int main(){
  int n,i;
  int A[MAX];
  int count; 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  count = BubbleSort(A,n);
  printf("%d\n",count);
  return 0;
}