#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()
 
template<class T,class U> inline bool chmin(T &a, U b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T,class U> inline bool chmax(T &a, U b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr ll inf = 3e18;
#line 3 "/home/defineprogram/Desktop/Library/structure/BIT.cpp"

template<class T>
class BIT{
	ll N;
	vector<T>bit;
	void add_(ll x,T y){
		while(x<=N){
			bit[x]+=y;x+=x&-x;
		}
	}
	T sum_(ll x){
		T res=0;
		while(x>0){
			res+=bit[x];x-=x&-x;
		}
		return res;
	}
public:
	ll lower_bound(T w){
		if(w<=0)return -1;
		ll x=0;
		ll k=1;while(k*2<=N)k*=2;
		for(;k>0;k/=2){
			if(x+k<=N&&bit[x+k]<w){
				w-=bit[x+k];
				x+=k;
			}
		}
		return x;
	}
	void add(ll x,T y){add_(x+1,y);}
	T sum(ll l,ll r){return sum_(r)-sum_(l);}
	BIT(ll x):N(x),bit(x+1){}
};
/*
@brief Binary Indexed Tree
@docs docs/BIT.md
*/
#line 3 "main.cpp"

int N;
int A[200005],B[200005];
int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N){
		cin>>A[i];
		B[A[i]]=i+1;
	}
	set<int>st;
	rep(i,N-1){
		st.insert(A[i]);
		if(st.upper_bound(i+1)==st.end()||++st.upper_bound(i+1)!=st.end()){
			cout<<"-1\n";return 0;
		}
	}
	st.clear();
	rev(i,N){
		if(!i)break;
		st.insert(A[i]);
		if(st.upper_bound(i)==st.begin()||--st.upper_bound(i)!=st.begin()){
			cout<<"-1\n";return 0;
		}
	}
	BIT<int> bit(N+5);
	ll cnt=0;
	rep(i,N){
		cnt+=bit.sum(A[i],N+1);
		bit.add(A[i],1);
	}
	if(cnt!=N-1){
		cout<<"-1\n";return 0;
	}
	rep(i,N){
		for(int j=B[i+1];j>i+1;j--){
			cout<<j-1<<"\n";
			B[A[j-2]]++;
			swap(A[j-2],A[j-1]);
		}
	}
}

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

lli gauss(lli u) {
  if(u % 2) {
    lli v = (u - 1LL) / 2LL;
    return u * v;
  }
  lli v = (u - 1LL);
  u /= 2LL;
  return u * v;
}


void solve() {
  lli n, k; cin >> n >> k;
  lli lim = 3LL * n;
  vi cnt(lim + 1LL);
  lli next = 1;
  lli lim2;
  if(n % 2) lim2 = ((n + 1LL) * 3LL) / 2LL;
  else lim2 = ((n  * 3LL) + 2) / 2LL;
  for(lli i = 3LL; i <= n + 1LL; ++i) {
     cnt[i] = cnt[i - 1] + next;
     ++next;
  }
  for(lli i = n + 2LL; i <= lim2; ++i) {
    cnt[i] = cnt[i - 1] + next;
    next -= 2;
  }
  for(lli i = lim; i > lim2; --i) {
    cnt[i] = cnt[lim - i + 3LL];
  }
  lli x;
  for(lli i = 3LL; i <= lim; ++i) {
    if(k > cnt[i]) k -= cnt[i];
    else {
      x = i;
      break;
    }
  }
  //deb(k);
  for(lli i = 1LL; i <= n; ++i) {
    lli left = (x - i);
    if(left > (2LL * n)) continue;
    lli cur = (2LL * n) - left + 1LL;
    cur = min(cur, left - 1LL);
    //deb(left);
    //deb(cur);
    if(k > cur) {
      k -= cur;
      continue;
    }
    for(lli j = 1LL; j <= n; ++j) {
      cur = (left - j);
      if(cur > n) continue;
      if(k == 1) {
        cout << i << " " << j << " " << cur << ENDL;
        return;
      }
      else --k;
    }
  }
}

int main(){ _
  solve();
  return 0;
}
