#include <bits/stdc++.h>
#define lc (o<<1)
#define rc ((o<<1)|1)
#define PB push_back
#define MK make_pair
using namespace std;
#define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl

const int maxn = 5000 + 5;
const int modu = 998244353; // 1e9 + 7
const int inf = 0x3f3f3f3f;
const double eps = 1e-5;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

typedef long long LL;

void read(LL &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}

void read(int &x) { LL y; read(y); x = (int)y; }
void read(char &ch) { char s[3]; scanf("%s", s); ch = s[0]; }
void read(char *s) { scanf("%s", s); }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }

int n, m;
int a[maxn];
LL inv[maxn], c[maxn], f[20][maxn];
int b[20];

int main() {
    // freopen("my.txt", "w", stdout);
    read(n, m);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = (modu - (modu/i))*inv[modu%i]%modu;
    c[0] = 1;
    for (int i = 1; i <= n; ++i)
        c[i] = (n-i+1)*inv[i]%modu*c[i-1]%modu;
    int nb = 0;
    while (m) {
        b[nb++] = m%2;
        m /= 2;
    }
    memset(f, 0, sizeof(f));
    f[nb-1][0] = 1;
    int tot = b[nb-1];
    for (int i = nb-2; i >= 0; --i) {
        for (int j = 0; j <= tot*2 + b[i]; ++j) if (j%2 == 0) {
            for (int k = 0; k <= j && k <= n; k += 2)
                f[i][j] = (f[i][j] + f[i+1][(j-k)/2]*c[k]) % modu;
        }
        tot = tot*2 + b[i];
    }
    printf("%lld\n", f[0][tot]);
	return 0;
}
#include <bits/stdc++.h>
#pragma GCC optimize(3)
#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
using namespace std;
const int N = 200010;
inline int read()
{
    int s = 0, w = 1;
    ri char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
    return s * w;
}
int n, a[N], pos[N], book[N];
vector<int> Ans;
signed main()
{
    n = read();
    for (ri int i = 1; i <= n; i++)
        a[i] = read(), pos[a[i]] = i;
    for (ri int i = 1; i <= n; i++)
    {
        while (i < pos[i])
        {
            if (book[pos[i]])
                return puts("-1") & 0;
            book[pos[i]] = 1;
            Ans.eb(pos[i]);
            int x = a[pos[i]], y = a[pos[i] - 1];
            int p = pos[i], q = pos[i] - 1;
            swap(a[pos[i]], a[pos[i] - 1]);
            pos[x] = q, pos[y] = p;
        }
    }
    if ((int)Ans.size() != n - 1)
        return puts("-1") & 0;
    for (auto i : Ans)
        printf("%lld\n", i - 1);
    return 0;
}