#include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) int N; i64 L; int Z; vector W; vector dp; int main() { cin >> N; cin >> L; W.resize(N); rep(i,N) cin >> W[i]; sort(W.begin(), W.end()); Z = W.back(); W.pop_back(); dp.assign(Z, Z+100); dp[0] = 0; for(i64 w : W){ vector> queues(Z+1); rep(i,Z) if(dp[i] <= Z) queues[dp[i]].push_back(i); w %= Z; rep(pred,Z){ rep(i, queues[pred].size()){ int p = queues[pred][i]; if(dp[p] != pred) continue; int nxp = (p + w); int nxd = pred; if(nxp >= Z){ nxp -= Z; nxd++; } if(dp[nxp] <= nxd) continue; dp[nxp] = nxd; queues[nxd].push_back(nxp); } } } i64 ans = L; rep(i,Z){ i64 U = (L + Z - i) / Z; if(i == 0) U--; ans -= min(U, dp[i]); } cout << ans << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;