#include <iostream>
using namespace std;
int main() {
int n;
while ( cin >> n ) {
int train[n], cnt = 0;
for ( int i = 0; i < n; ++i )
cin >> train[i];
for ( int i = 0; i < n - 1; ++i )
for ( int j = 0; j < n - i - 1; ++j )
if ( train[j] > train[j + 1] ) {
train[j] ^= train[j + 1] ^= train[j] ^= train[j + 1];
++cnt;
}
cout << cnt << endl;
}
return 0;
}