#include <stdio.h>
const int MAX_N = 200000;

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

int main(void) {
  int n, cnt = 0;
  int i, j;
  int ary[MAX_N];

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

  for (i = 0; i < n; i++) {
    for (j = n-1; j > i; j--) {
      if (ary[j] < ary[j-1]) {
        swap(&ary[j], &ary[j-1]);
        cnt++;
      }
    }
  }

  printf("%d\n", cnt);

  return 0;
}