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

using ll = long long;
using ld = long double;
using lp = pair<ll, ll>;
using lmap = map<int, int>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define eb emplace_back

constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1 << 30;
constexpr ll LINF = 1LL << 62;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
inline void ans_exit(string msg) { cout << msg << endl; exit(0); }
template<class T> bool chmin(T &a, T b) {if(a > b){a = b; return 1;} return 0;}
template<class T> bool chmax(T &a, T b) {if(a < b){a = b; return 1;} return 0;}

int main() {
    ll n; cin >> n;
    vector<ll> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    vl pos(n);
    rep(i, n) pos[p[i]] = i;

    set<ll> swapped; vl ans;
    rep(i, n) {
        while(pos[i] != i) {
            pos[p[pos[i] - 1]]++;
            swap(p[pos[i]], p[pos[i] - 1]);
            pos[i]--;
            if(swapped.count(pos[i])) ans_exit("-1");
            swapped.insert(pos[i]);
            ans.pb(pos[i]);
        }
    }

    if((int)ans.size() != n - 1) ans_exit("-1");
    rep(i, n - 1) cout << ans[i] + 1 << endl;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         PI         acos(-1)
#define        lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))
#define         max5        100000
#define         max6        1000000
#define         mod       1000000

vi pt;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);


    int n,k,i,a,j;

    cin >> n;

    int ar[n+10];
    int po[n+10];
    int vis[n+10]={0};

    int ok  = 1;
    for(i=1; i<=n; i++)
    {
        cin >> ar[i];
        po[ar[i]] = i;
    }

    for(i=1;i<=n;i++)
    {
        if(vis[i])
        {
            if(i!=ar[i])return cout<<-1<<endl,0;
            continue;
        }
        int st = po[i];

        for(j=st-1;j>=i;j--)
        {
            swap(ar[j],ar[j+1]);
            pt.pb(j);
            vis[j]=1;
        }
    }

    if(pt.size()!=n-1)return cout << -1 << endl,0;
    for(auto x : pt)cout << x << endl;
}
