#include <iostream>
using namespace std;
int n;
int main() {
cin >> n;
int arr[n];
for(int i=0; i<n; i++) cin >> arr[i];
int counter=0;
for(int u=0; u<n;u++) {
for(int j=1; j<(n-u); j++) {
if((arr[j]<arr[j-1])) {
int prev;
prev = arr[j-1];
arr[j-1] = arr[j];
arr[j] = prev;
counter++;
//for(int t=0; t<n; t++) cout << arr[t] << " ";
//cout << " " << u;
//cout<<'\n';
}
}
}
cout << counter;
return 0;
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG47CgppbnQgbWFpbigpIHsKICAgIGNpbiA+PiBuOwogICAgaW50IGFycltuXTsKCiAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspIGNpbiA+PiBhcnJbaV07CiAgICBpbnQgY291bnRlcj0wOwogICBmb3IoaW50IHU9MDsgdTxuO3UrKykgewogICAgICAgIGZvcihpbnQgaj0xOyBqPChuLXUpOyBqKyspIHsKICAgICAgICAgICAgaWYoKGFycltqXTxhcnJbai0xXSkpIHsKICAgICAgICAgICAgCQogICAgICAgICAgICAgICAgaW50IHByZXY7CiAgICAgICAgICAgICAgICBwcmV2ID0gYXJyW2otMV07CiAgICAgICAgICAgICAgICBhcnJbai0xXSA9IGFycltqXTsKICAgICAgICAgICAgICAgIGFycltqXSA9IHByZXY7CiAgICAgICAgICAgICAgICBjb3VudGVyKys7CiAgICAgICAgICAgICAgICAJLy9mb3IoaW50IHQ9MDsgdDxuOyB0KyspIGNvdXQgPDwgYXJyW3RdIDw8ICIgIjsKICAgICAgICAgICAgICAgIAkvL2NvdXQgPDwgIiAgICIgPDwgdTsKICAgICAgICAgICAgICAgIAkvL2NvdXQ8PCdcbic7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGNvdW50ZXI7CiAgICByZXR1cm4gMDsKfQ==