#include"bits/stdc++.h" using namespace std; int s[1005]; int main(){ int n,m,d; cin>>n>>m; while(n--){ cin>>d; sort(s,s+m); s[0]+=d;} sort(s,s+m); cout<<s[m-1]; }