#include using namespace std; using lint = long long; int main() { lint n, m, k; cin >> n >> m >> k; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; a.push_back(0); n++; vector vec(n*n*n); int cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { vec[cnt] = a[i]+a[j]+a[k]; cnt++; } } } sort(vec.begin(), vec.end()); lint ans = -1; for (int i = 0; i < n*n*n; i++) { auto itr = upper_bound(vec.begin(), vec.end(), m-vec[i]); if (itr == vec.begin()) continue; else { int idx = itr-vec.begin()-1; if (vec[i]+vec[idx] > m) continue; else ans = max(ans, vec[i]+vec[idx]); } } cout << ans << endl; }