//#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;


#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9+7; //998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = atcoder::modint1000000007;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI p(n), b(n), usd(n-1);
	rep(i, n){
		int z; cin >>z; z--;
		p[i] = z;
		b[z] = i;
	}
	VI ans;
	rep(i, n){
		if(p[i]==i) continue;
		int zs = b[i];
		for(int j=zs; j-1>=i ; j--){
			if(usd[j-1]==1){ usd[0] = 1111111; goto lpout;}
			swap(p[j], p[j-1]);
			ans.push_back(j-1);
			b[p[j]] = j;
			b[p[j-1]] = j-1;
			usd[j-1]=1;
		}
		
	}
	lpout:
	if(count(all(usd),1) != n-1){cout <<"-1\n"; return 0;}
	rep(i, n) if(p[i] !=i){cout <<"-1\n"; return 0;}
	for(auto x :ans) cout<<x+1<<"\n";
	return 0;
}

#define ll loli
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define push emplace
#define lb(x, v) lower_bound(all(x), v)
#define ub(x, v) upper_bound(all(x), v)
#define sz(x) (int)(x.size())
#define re(x) reverse(all(x))
#define uni(x) x.resize(unique(all(x)) - x.begin())
#define all(x) x.begin(), x.end()
#define mem(x, v) memset(x, v, sizeof x); 
#define int long long
#define pii pair<int, int>
#define inf 1e9
#define INF 1e18
#define mod 1000000007
#define F first
#define S second
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define chmax(a, b) (a = (b > a ? b : a))
#define chmin(a, b) (a = (b < a ? b : a))
using namespace std;

void trace_() {cerr << "\n";}
template<typename T1, typename... T2> void trace_(T1 t1, T2... t2) {cerr << ' ' << t1; trace_(t2...); }
#define trace(...) cerr << "[" << #__VA_ARGS__ << "] :", trace_(__VA_ARGS__);

int n;

signed main() {
	IO;	
	cin >> n;
	int i, sum = 0;
	for (i = 1; sum < n; i++) {
		sum += i;
	}
	cout << i - 1 << '\n';	
}
