#include<stdio.h>
int main(){

  int i,j,n,a[200001];

  scanf("%d", &n );

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

  int cnt,k;
  cnt = 0;

  for ( i = 0; i < n - 1; i++ ){
    for ( j = n - 1; j > i; j-- ){
      if ( a[j] < a[ j - 1 ] ){
	k = a[j];
	a[j] = a[ j - 1 ];
	a[ j - 1 ] = k;
	cnt += 1;
      }
    }
  }

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

  return 0;

}