#include <stdio.h>

#define N 262144

void swap(int *x, int *y) {
  int tmp;

  tmp = *x;
  *x = *y;
  *y = tmp;
}

int bubbleSort(int n, int *A) {
  int i, j, cnt = 0;

  for (i = 0; i < n; i++) {
    for (j = n - 1; i < j; j--) {
      if (A[j] < A[j-1]) {
	swap(&A[j], &A[j-1]);
	cnt++;
      }
    }
  }
  return cnt;
}
	
int main(void){
  int i, n, A[N] = {0};

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