#include <stdio.h>
#include <stdlib.h>

void swap(long *A, long i, long j) {
  long temp;
  temp = A[i];
  A[i] = A[j];
  A[j] = temp;
}

int main()
{
  long i,j,n,*a,count;
  scanf("%ld", &n);
  a = (long*)malloc(sizeof(long) * n);
  for (i = 0; i < n; i++) {
    scanf("%ld", a+i);
  }
  count = 0;
  for (i = 0; i < n; i++) {
    for (j = n-1; j > i; j--) {
      if(a[j] < a[j-1]) {
	swap(a,j,j-1);
	count++;
      }
    }
  }

  printf("%ld\n", count);
  
  return 0;
}