#include using namespace std; int n, k; long long m; long long solve(vector a, vector b){ long long res = 0; for(auto x : a){ if(x > m) continue; res = max(res, x); auto iter = upper_bound(b.begin(), b.end(), m - x); if(iter == b.begin()) continue; iter--; res = max(res, x + *iter); } return res; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k; vector a(n + 1); for(int i = 0; i < n; i++){ cin >> a[i]; } a[n] = 0; sort(a.begin(), a.end()); vector> b(3); vector c = a; b[0] = c; for(int i = 1; i <= 2; i++){ vector tmp; for(auto x : c){ for(auto y : a){ tmp.push_back(x + y); } } c = tmp; b[i] = c; sort(b[i].begin(), b[i].end()); } long long ans = 0; if(k == 1){ ans = solve(b[0], {0}); }else if(k == 2){ ans = solve(b[0], b[0]); }else if(k == 3){ ans = solve(b[0], b[1]); }else if(k == 4){ ans = solve(b[1], b[1]); }else if(k == 5){ ans = solve(b[1], b[2]); }else if(k == 6){ ans = solve(b[2], b[2]); } cout << ans << endl; }