#include using namespace std; void calc(int const sum, vector const a, int const K, vector &com){ vector na(a); if(na.empty()) return; if(sum+na.back()>K) return; int tmp=na.back(); na.pop_back(); com.push_back(sum+tmp);; calc(sum, na, K, com); calc(sum+tmp, na, K, com); } int main(){ int N,K,in; vector a, com; cin >> N >> K; while(cin >> in) a.push_back(in); sort(a.begin(),a.end(),greater()); calc(0,a,K,com); sort(com.begin(),com.end()); if(!com.empty()) cout << com.back() << endl; else cout << 0 << endl; return 0; }