#include using namespace std; void calc(int const sum, vector const a, int const K, vector &com){ vector na(a); for(int i=0;iK) return; int tmp=na.back(); na.pop_back(); calc(sum, na, K, com); calc(sum+tmp, na, K, com); com.push_back(sum+tmp); } } 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()); cout << com.back() << endl; return 0; }