/*
ID: gurban1
LANG: C++
TASK: 
*/
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int maxn=5e3+5;
const int mod=998244353;
int n,m;
ll f[maxn],inv[maxn];
ll dp[maxn][maxn];

ll binmod(ll a,ll b) {if(b==0)return 1;ll x=binmod(a*a%mod,b>>1);return b&1?x*a%mod:x;}

ll choose(int a,int b){
	return (((f[a] * inv[b]) % mod)*inv[a-b])%mod;
}

int main(){
	// freopen("","r",stdin);
	// freopen("","w",stdout);

	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;

	f[0] = 1;
	for(int i = 1;i <= n;i++) f[i] = (f[i-1] * i) % mod;
	inv[n] = binmod(f[n],mod-2);
	
	for(int i = n-1;i >= 0;i--) inv[i] = ((i+1) * inv[i+1])%mod;

	for(int i = 0;i <= n;i += 2) dp[0][i] = choose(n,i);

	// for(int i = 0;i <= n;i+=2) cout<<i<<' '<<dp[0][i]<<'\n';

	int lg = __lg(m);
	for(int i = 1;i <= lg;i++){
		for(int j = 0;j <= n;j += 2){
			for(int k = (j<<i);k <= m;k += 2){
				ll cnt = (choose(n,j) * dp[i-1][k-(j<<i)])%mod;
				dp[i][k] = (dp[i][k] + cnt)%mod;
			}
		}
	}
	cout<<dp[lg][m];
}
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define ad(a,b) a=(a+b)%mod;
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
#define X 200010
ll fac[X],ivf[X];
void initfac(){
	fac[0]=1;
	for(ll i=1;i<X;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=0;i<X;i++)ivf[i]=po(fac[i],mod-2);
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll n,p[200010],place[200010];
	cin>>n;
	rep(i,n){
		cin>>p[i]; p[i]--;
		place[p[i]]=i;
	}
	vector<ll> v;
	bool ok=1;
	ll s=0;
	while(1){
		ll i=place[s]-1;
		if(i<s){ok=0;break;}
		for(;i>=s;i--){
			v.push_back(i);
			swap(p[i+1],p[i]);
		}
		s=place[s];
		if(s==n-1)break;
	}
	rep(i,n)ok&=(p[i]==i);
	if(ok){
		rep(i,v.size())cout<<v[i]+1<<"\n";
	}
	else cout<<-1<<endl;
}

