//將數列由小到大排列
//可能重複做超過一次,因此我用while來判斷啥時停,啥時不該停
#include<iostream>
using namespace std;
int main() {
int n;
while (cin>>n)
{
int test[10001] = {};
for (int i = 0; i < n; i++) cin >> test[i];
int count = 0, trigger = 0; //當trigger為0時就停下,1就繼續
do {
trigger = 0;
/*將數列進行交換*/
for (int i = 0; i < n; i++) {
if (i != n - 1 && test[i] > test[i + 1]) {
int temp = test[i];
test[i] = test[i + 1];
test[i + 1] = temp;
trigger = 1;
count++;
}
}
if (trigger == 0)break; //若這一輪都沒有進行交換,則離開while,輸出答案
} while (trigger == 1);
cout << count << endl;
}
return 0;
}