#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int total = 0;
    int arr[n];
    int ans[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      ans[i] = arr[i];
    }
    sort(ans, ans + n);
    for (int i = 0; i < n; i++) {
      while (arr[i] != ans[i]) {
        for (int i = 1; i < n; i++) {
          if (arr[i] < arr[i - 1]) {
            total += 1;
            int temp = arr[i];
            arr[i] = arr[i - 1];
            arr[i - 1] = temp;
          }
        }
      }
    }
    cout << total << '\n';
  }
}
