#include #include #include #include #include #include #include #define REP(i,n) for(int i=0;i a; cin >> n >> k; REP(i, n){ cin >> x; a.push_back(x); } sort(a.begin(), a.end()); auto itr = a.end(); itr--; while (1){ if (*itr + ans <= k){ ans += *itr; } //cout << ans << endl; if (itr == a.begin()){ break; } itr--; } cout << ans << endl; return 0; }