import java.util.Scanner; public class No617 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); // 荷物の個数 int K = sc.nextInt(); // 持てる重さの最大値 int weight[] = new int[30]; //各荷物の重さ(=価値) int dp[][] = new int[30][2000010]; for(int i = 0;i < N;i++) { weight[i] = sc.nextInt(); } //初期化 入力 for(int i = 0;i <= K;i++) { dp[0][i] = 0; } for(int i = 0;i < N;i++) { for(int j = 0;j <= K;j++) { if(j >= weight[i]) { dp[i+1][j] = Math.max(dp[i][j - weight[i]] + weight[i],dp[i][j]); }else { dp[i+1][j] = dp[i][j]; } } } System.out.println(dp[N][K]); } }