#include <bits/stdc++.h>
int main() {
  int dataset[100];
  int length = 0;
  int i, j, count, tmp;
  while (scanf("%d", &length) && length) {
    for (i = 0; i < length; i++) scanf("%d", &dataset[i]);
    count = 0;
    for (i = length - 1; i >= 0; i--) {
      for (j = 0; j < i; j++) {
        if (dataset[j] > dataset[j + 1]) {
          tmp = dataset[j];
          dataset[j] = dataset[j + 1];
          dataset[j + 1] = tmp;
          count++;
        }
      }
    }
    printf("[%d]\n", count);
  }
  return 0;
}
