#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


ll dp[205][100005];

int main(int argc, char* argv[])
{
    long n, x;
    scanf("%ld%ld", &n, &x);

    vector<long> s(n);
    long i,j;
    for(i=0; i<n; i++) {
        scanf("%ld", &s[i]);
    }
    sort(s.rbegin(), s.rend());

    dp[0][x]=1;
    for(i=0; i<n; i++) {
        for(j=0; j<=x; j++) {
            if(dp[i][j]) {
                if(i<n-1) {
                    dp[i+1][j] = (dp[i+1][j] + (dp[i][j]* (n-i-1)))%MOD;
                    dp[i+1][j%s[i]] = (dp[i+1][j%s[i]] + dp[i][j])%MOD;
                }
                else {
                    dp[i+1][j%s[i]] = (dp[i+1][j%s[i]] + dp[i][j])%MOD;
                }
            }
        }
    }

    ll ans=0;
    for(i=0; i<s[n-1]; i++) {
        ans = (ans + i*dp[n][i])%MOD;
    }
    printf("%lld\n", ans);

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

using LL = long long;
using vi = vector<int>;
using pii = pair<int,int>;
#define ST first
#define ND second
#define PB push_back

const int nax = 301;
const int mod = 998244353;
int n,a[nax];
int dp[nax][nax*nax];
int ans,sum,sub;

int main() {
	scanf("%d",&n);
	for(int i=1; i<=n;i++) {
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ans=1;
	for(int i=1; i<n;i++) {
		ans=((LL)ans*3)%mod;
	}
	dp[0][0] = 1;
	for(int i=1; i<=n;i++) {
		for(int s=0; s<=sum; s++) {
			dp[i][s] = (2*dp[i-1][s])%mod;
			if(s-a[i]>=0) {
				dp[i][s]= (dp[i][s]+dp[i-1][s-a[i]])%mod;
			}
		}
	}
	for(int i=1; i<=sum;i++) {
		if(i>=(sum+1)/2) {
			sub=(sub+dp[n][i])%mod;
		}
	}
	dp[0][0] = 1;
	for(int i=1; i<=n;i++) {
		for(int s=0; s<=sum;s++) {
			dp[i][s] = dp[i-1][s];
			if(s-a[i]>=0) {
				dp[i][s]= (dp[i][s]+dp[i-1][s-a[i]])%mod;
			}
		}
	}
	if(sum%2==0) {
		sub=(sub-dp[n][sum/2]+mod)%mod;
	}
	int res = (((ans-sub)%mod)+mod)%mod;
	res = ((LL)res*3)%mod;
	printf("%d",res);
}
