#include <bits/stdc++.h>
 
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 2e5 + 10, MOD = 1e9 + 7;
int id[N], P[N], F[N], n; ll inv = 0;

void update(int pos, int x) {
	for (pos++; pos < N; pos += pos & -pos) F[pos] += x;
}

ll get(int pos, ll res = 0) {
	for (pos++; pos; pos -= pos & -pos) res += F[pos];
	return res;
}

int main() {
	scanf("%d", &n); vector<int> vec;
	for (int i = 1; i <= n; i++) scanf("%d", &P[i]), inv += get(N - 2) - get(P[i]), update(P[i], 1), id[P[i]] = i;
	if (inv != n - 1) return !printf("-1\n");
	for (int i = 1; i <= n; i++) {
		for (int j = id[i] - 1; j >= i; j--) {
			vec.push_back(j);
			id[P[j]] = j + 1, id[P[j + 1]] = j;
			swap(P[j], P[j + 1]);
		}
	}
	for (int x : vec) printf("%d\n", x);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long i64;

void test_case() {
  int n;
  while (scanf("%d", &n) != EOF) {
    vector<int> p(n+1);
    vector<bool> used(n+1);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &p[i]);
    }
    vector<int> a;
    int k = 0;
    for (int i = 2; i <= n; i++) {
      k++;
      if (p[i-1] > p[i]) {
        a.push_back(i-1);
        used[i-1] = true;
        swap(p[i-1], p[i]);
        k--;
      }
      for (int j = i-1; j > 1 && k > 0; j--) {
        if (p[j-1] > p[j]) {
          if (used[j-1]) {
            break;
          }
          a.push_back(j-1);
          used[j-1] = true;
          swap(p[j-1], p[j]);
          k--;
        } else {
          break;
        }
      }
    }
    bool sorted = true;
    for (int i = 2; i <= n; i++) {
      if (p[i-1] > p[i]) {
        sorted = false;
        break;
      }
    }
    bool bad = !sorted || (int) a.size() != n-1;
    if (bad) {
      printf("-1\n");
    } else {
      for (int i : a) {
        printf("%d\n", i);
      }
    }
  }
}

int main() {
  test_case();
  return 0;
}
