#include<stdio.h>
  
int bubble_sort(int* A, int N){
  int i,j, cnt = 0,flag = 0;
  for(i = 0; i < N; i++)
  {
      flag = 0;
      for(j = N-1; j >= i+1; j--)
      {
          if(A[j] < A[j-1]){
              int tmp = A[j];
              A[j] = A[j-1];
              A[j-1] = tmp;
              cnt++;
              flag = 1;
          }
          if(j == i && flag == 0)
          {
              return cnt;
          }
      }
  }
}
  
int main(){
  int i,N,data[100];
  scanf("%d",&N);
  for(i = 0; i < N; i++) scanf("%d",&data[i]);
  printf("%d\n",bubble_sort(data,N));
  return 0;
}
