#include <bits/stdc++.h>
int main(void) {
  int n;
  while (scanf("%d", &n), n != 0) {
    int m[110], i;
    for (i = 0; i < n; i++) scanf("%d", &m[i]);
    int count = 0, work, j;
    for (i = 0; i < n - 1; i++) {
      for (j = i + 1; j < n; j++) {
        if (m[i] > m[j]) {
          work = m[i];
          m[i] = m[j];
          m[j] = work;
          count++;
        }
      }
    }
  }
  return 0;
}
