#include <iostream>
#include <string>
#include <limits.h>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
}
bool flag;
int res = 0;
for(int i = 0; i < n - 1; i++){
flag = false;
for(int j = 0; j < n - 1 - i; j++){
if(a[j] > a[j + 1]){
res++;
flag = true;
int tmp = a[j];
a[j] = a[j + 1];
a[j + 1] = tmp;
}
if(!flag) break;
}
}
cout << res << endl;
return 0;
}