#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    int data[100000] = {};
    unsigned long long count = 0;
    for (int i = 0; i < n; i++) {
      cin >> data[i];
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (data[i] > data[j]) {
          swap(data[i], data[j]);
          count++;
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
