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

int main(){
    int n;
    long long X;
    scanf("%d %lld", &n, &X);

    vector <int> a(n);
    for(int i = 0; i < n; i++)scanf("%d", &a[i]);

    long long res = X;
    for(int k = 1; k <= n; k++){
        vector < vector <long long> > dp(k + 1, vector <long long> (k, -1));
        dp[0][0] = 0;

        for(int i = 0; i < n; i++){
            for(int j = k; j >= 1; j--)
            for(int r = 0; r < k; r++){
                long long c = dp[j - 1][(r - (a[i] % k) + k) % k];
                if(c != -1 && (dp[j][r] == -1 || dp[j][r] < c + a[i]))
                    dp[j][r] = c + a[i];
            }
        }

        if(dp[k][X % k] != -1)res = min(res, (X - dp[k][X % k]) / k);
    }
    printf("%lld\n", res);
    
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N = 5005;
int mod = 998244353;

int n , m;
ll pw[N];
ll a[N][N];

int main()
{
    // freopen(".inp","r",stdin);
    // freopen(".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;

    pw[0] = 1;
    for (int i = 1 ; i < N ; ++i) pw[i] = pw[i - 1] * (ll) m % mod;

    a[0][0] = 1;
    for (int j = 1 ; j < N ; ++j)
    {
        a[0][j] = 1;
        for (int i = 1 ; i < N ; ++i)
        {
            a[i][j] = a[i - 1][j] * (ll) j % mod;
        }
    }

    for (int i = 0 ; i < N ; ++i)
    {
        for (int j = 1 ; j < N ; ++j)
        {
            a[i][j] = (a[i][j] + a[i][j - 1]) % mod;
        }
    }

    ll ans = pw[n] * n;

    for (int i = 1 ; i <= n ; ++i)
    {
        for (int j = i + 1 ; j <= n ; ++j)
        {
            ans = (ans - a[j - i - 1][m - 1] * pw[n - (j - i + 1)] + (ll) mod * (ll) mod) % mod;
        }
    }

    cout << ans;

}
