#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} template ostream &operator<<(ostream &os,const pair&p){ os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector &a){ for(auto &i:a)is>>i; return is; } #define reps(i,a,n) for(int i=(a);i<(n);i++) #define rep(i,n) reps(i,0,n) #define all(x) x.begin(),x.end() ll myceil(ll a,ll b){return (a+b-1)/b;} int main(){ int n,m,K; cin>>n>>m>>K; vectora(n); cin>>a; a.push_back(0); n++; if(K==1){ int ans=0; for(auto i:a)if(i<=m)chmax(ans,i); cout<b; for(auto i:a)for(auto j:a)b.push_back(i+j); vectorc; for(auto i:a)for(auto j:a)for(auto k:a)c.push_back(i+j+k); sort(all(b)),sort(all(c)); int ans=0; if(K==4){ for(auto i:b){ int cu=upper_bound(all(b),m-i)-b.begin(); cu--; if(cu<0)continue; chmax(ans,i+b[cu]); } } else if(K==5){ for(auto i:b){ int cu=upper_bound(all(c),m-i)-c.begin(); cu--; if(cu<0)continue; chmax(ans,i+c[cu]); } } else{ for(auto i:c){ int cu=upper_bound(all(c),m-i)-c.begin(); cu--; if(cu<0)continue; chmax(ans,i+c[cu]); } } cout<