# 코딩 문제 관련/파이썬
백준 2798번(python)
Hwiyong Jo
2019. 7. 6. 20:18
from itertools import combinations
N, M = map(int, input().split())
num_list = list(map(int, input().split()))
res_list = []
for comb in combinations(num_list, 3):
comb_sum = sum(comb)
res_list.append(comb_sum)
res_list = list(filter(lambda t: t <= 0,list(set(map(lambda x : x - M, res_list)))))
res_list = sorted(res_list, key = int, reverse = True)
print(M + res_list[0])