#include<stdio.h>
#define MAX 200000

int bubbleSort(int *);

int n;

int main()
{
  int i;
  int A[MAX];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }

  printf("%d\n",bubbleSort(A));

  return 0;
}

int bubbleSort(int *A)
{
  int cnt = 0,i,j,tmp;
  for(i = 0;i < n;i++){
    for(j = n-1;j >= i+1;j--){
      if(A[j] < A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	cnt++;
      }
      if(n >=  MAX){
	return 0;
	break;
      }
    }
  }
  return cnt;
}