#include<bits/stdc++.h>
using namespace std;int n, m, x;int a[105];intmain(){
cin >> n >> m;for(int i =1; i <= n; i ++){
cin >> x;int t =1;for(int j =2; j <= m; j ++){if(a[j]< a[t]) t = j;}
a[t]+= x;}int maxx =0;for(int j =1; j <= m; j ++){
maxx =max(maxx, a[j]);}
cout << maxx;return0;}
#include<bits/stdc++.h>
using namespace std;int n, m, x;
priority_queue <int, vector<int>, greater<int>> q;intmain(){
cin >> n >> m;for(int i =1; i <= m; i ++) q.push(0);for(int i =1; i <= n; i ++){
cin >> x;int t = q.top();
q.pop();
q.push(t + x);}for(int j =1; j < m; j ++) q.pop();
cout << q.top();return0;}