#include <iostream>

constexpr int N = 5005;
constexpr int p = 998244353;

int add(int x, int y) { return (x += y) >= p ? x - p : x; }
int sub(int x, int y) { return (x -= y) < 0 ? x + p : x; }
int mul(int x, int y) { return (long long)x * y % p; }

int n, m;
int f[N], g[N];

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    std::cin >> n >> m;
    g[0] = 1;
    for (int i = 1; i <= n; ++i) g[i] = mul(g[i - 1], m);
    int ans = mul(n, g[n]);
    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= n; ++j) {
            f[j] = add(mul(f[j - 1], i), sub(g[j - 1], f[j - 1]));
            ans = sub(ans, mul(f[j - 1], g[n - j]));
        }
    std::cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

const int N = 105;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
#define debug(x) cerr << #x << " :: " << x << '\n';
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long x, a[N], dp[2][N][N][N];
int n, COL, K;

long long fun(int pos, int cnt, int rem) {
    if (pos == n || cnt == K) {
        long long vaL = x - rem;
        if (vaL % K == 0 && cnt == K) {
            return vaL / K;
        }
        return INF;
    }
    long long &tmp = dp[0][pos][cnt][rem];
    long long &vmp = dp[1][pos][cnt][rem];
    if (vmp == COL) {
        return tmp;
    }
    vmp = COL;
    tmp = INF;
    long long vaL = a[pos] + rem;
    tmp = min(tmp, fun(pos + 1, cnt, rem));
    tmp = min(tmp, fun(pos + 1, cnt + 1, vaL % K) - (vaL / K));
    return tmp;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = INF;
    for (int i = 1; i <= n; i++) {
        COL++, K = i;
        ans = min(ans, fun(0, 0, 0));
    }
    cout << ans << '\n';
    return 0;
}
