const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

let array;
let index = 0;
let n;
let m;
while (line = lines.shift()) {
    if(index === 0){
        const test = line.split(' ').map(Number);
        // array = line.split(' ').map(Number);
        n = test[0];
        m = test[1];
    } else {
        array = line.split(' ').map(Number);
    }
    index ++;
}
let answer = 0;
// const array = [10,20,30];

for(let i = 0; i<n ;i++){
    for(let j = 0;j<n;j++){
        if(i === j){
            continue;
        }
        const test = array [i] + array [j];
        if(test > answer && test <= m){
            answer = test;
        }
    }
    // console.log('BREAK');
}
console.log(answer);
