#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 = 300; mint ans = 0; vector g(n+1,1),h(n,0), h2(n); for(int i = 0; i < n; i++) h[i] = m/a[i], g[i+1] = g[i]*h[i], h2[i] = mint(1)/h[i]; vector> c(m+1); e = min(e,m); vector> c2(e+1,vector(n+1,0)); for(int i = 0; i < n; i++) { c[a[i]].push_back(i); if(a[i] <= e) c2[a[i]][i+1]+=h2[i]; for(int j = 1; j <= e; j++) c2[j][i+1]+=c2[j][i]; } for(int i = 0; i < n; i++) { for(int j = 1; j <= e; j++) { int z = m/a[i]; mint u = c2[j][n]-c2[j][i+1]; if(u.val() == 0) continue; int x = a[i]*j/gcd_f(a[i],j); ans+=(floor_sum(z,j,a[i],a[i])-m/x)*g[n]*u*h2[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 z = m/j; mint u = c2[j][i]; if(u.val() == 0) continue; int x = (a[i]*j/gcd_f(a[i],j)); ans+=(floor_sum(z,j,a[i],a[i])-m/x)*g[n]*u*h2[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]*h2[s[i][j]]; for(int j = 0; j < l; j++) seg.add(s[i][j],h2[s[i][j]]); } cout << ans.val() << endl; }