#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <class T>
T RoundOff(T a) {
  return int(a + .5 - (a < 0));
}
template <class T, class C>
void chmax(T& a, C b) {
  if (a < b) a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  if (b < a) a = b;
}
template <class T, class C>
pair<T, C> mp(T a, C b) {
  return make_pair(a, b);
}
int main() {
  for (int n; cin >> n && n;) {
    int res = 0;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int j = n - 1; 0 < j; j--)
      for (int i = 0; i < j; i++) {
        if (v[i] > v[i + 1]) {
          swap(v[i], v[i - 1]);
          res++;
        }
      }
    cout << res << endl;
  }
}
