#include using namespace std; const int INF = 1000000000; int main(){ int N, M; cin >> N >> M; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } sort(A.begin(), A.end(), greater()); vector> dp(N + 1, vector(M + 1, -INF)); dp[0][0] = 0; for (int i = 0; i < N; i++){ for (int j = 0; j <= M; j++){ if (dp[i][j] >= 0){ dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if (i < N - 1){ int d = A[i] - A[i + 1]; if (j + d <= M){ dp[i + 2][j + d] = max(dp[i + 2][j + d], dp[i][j] + A[i]); } } } } } int ans = 0; for (int i = 0; i <= M; i++){ ans = max(ans, dp[N][i]); } cout << ans << endl; }