#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, a[10005], ct = 0;//ct:数据交换的次数
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> a[i];
for(int i = 1; i <= n-1; ++i)
for(int j = 1; j <= n-i; ++j)
if(a[j] > a[j+1])
{
swap(a[j], a[j+1]);
ct++;
}
cout << ct;
return 0;
}