#include using namespace std; #include using namespace atcoder; using mint = modint998244353; #define int long long int gcd_f(int x, int y) { if(x < y) swap(x,y); if(y == 0) return x; if(x%y == 0) return y; else return gcd_f(y,x%y); } struct Segtree { vector> num; vector p; int n; Segtree(int N) { n = N; num.resize(n); p.resize(n+1); p[0] = 1; for(int i = 0; i < n; i++) p[i+1] = p[i]*2; for(int i = 0; i < n; i++) num[i].assign(p[i],0); } void add(int x, mint y) { num[n-1][x] = num[n-1][x]+y; int t = x; for(int i = n-2; i >= 0; i--) { t/=2; num[i][t] = num[i+1][t*2]+num[i+1][t*2+1]; } } mint sum_calc(int t, int l, int r, int x, int y) { int m = (l+r)/2; if(t == n) return 0; if(x <= l && r <= y) return num[t][l/p[n-t-1]]; if(r <= x || y <= l) return 0; return sum_calc(t+1,l,m,x,y)+sum_calc(t+1,m,r,x,y); } mint sum(int l, int r) { return sum_calc(0,0,p[n-1],l,r); } }; int m; signed main() { int n; cin >> n >> m; vector a(n); for(int i = 0; i < n; i++) cin >> a[i]; int e = 200; mint ans = 0; vector g(n+1,1),h(n,0); for(int i = 0; i < n; i++) h[i] = m/a[i], g[i+1] = g[i]*h[i]; vector> d(m+1); vector> c(m+1); for(int i = 0; i < n; i++) c[a[i]].push_back(i); for(int i = 0; i <= m; i++) { int l = c[i].size(); d[i].resize(l+1,0); for(int j = 0; j < l; j++) d[i][j+1] = d[i][j]+mint(1)/h[c[i][j]]; } for(int i = 1; i <= n; i++) e = min(e,m); for(int i = 0; i < n; i++) { for(int j = 1; j <= e; j++) { int f = upper_bound(c[j].begin(),c[j].end(),i)-c[j].begin(); int z = m/a[i]; int L = c[j].size(); mint u = d[j][L]-d[j][f]; int x = a[i]*j/gcd_f(a[i],j); ans+=(floor_sum(z,j,a[i],a[i])-m/x)*g[n]*u/h[i]; //cout << i << ' ' << j << ' ' << ans.val() << endl; } } for(int i = 0; i < n; i++) { if(a[i] <= e) continue; for(int j = 1; j <= e; j++) { int f = lower_bound(c[j].begin(),c[j].end(),i)-c[j].begin(); int z = m/j; int L = c[j].size(); mint u = d[j][f]; int x = (a[i]*j/gcd_f(a[i],j)); ans+=(floor_sum(z,j,a[i],a[i])-m/x)*g[n]*u/h[i]; //cout << i << ' ' << j << ' ' << ans.val() << endl; } } vector> s(m+1); for(int i = 0; i < n; i++) { if(a[i] <= e) continue; for(int j = a[i]; j <= m; j+=a[i]) s[j].push_back(i); } Segtree seg(17); for(int i = e+1; i <= m; i++) { int l = s[i].size(); //cout << l << endl; for(int j = 0; j < l; j++) ans+=seg.sum(s[i][j]+1,n)*g[n]/h[s[i][j]]; for(int j = 0; j < l; j++) seg.add(s[i][j],mint(1)/mint(h[s[i][j]])); } cout << ans.val() << endl; }