#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; int N, K; bool dp[25][2020202]; int A[25]; int main() { cin >> N >> K; for (int i = 0; i < N; i++) cin >> A[i]; dp[0][0] = true; for (int j = 0; j <= K; j++) { for (int i = 0; i < N; i++) { dp[i + 1][j] = dp[i][j]; if (j - A[i] >= 0 && dp[i][j - A[i]]) dp[i + 1][j] = true; } } //for (int i = 0; i <= N; i++) { // for (int j = 0; j <= K; j++) cout << dp[i][j] << " \n"[j == K]; //} int ans = 0; for (int i = 0; i <= K; i++) if (dp[N][i]) ans = i; cout << ans << endl; return 0; }