#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(ll i=0;i> N >> M; priority_queue, greater> q; REP(i,M) q.push(0); REP(i,N){ ll t; cin >> t; ll x=q.top(); q.pop(); q.push(x+t); } ll mx=0; while(!q.empty()){ ll x=q.top(); q.pop(); mx=max(mx,x); } cout << mx << endl; return 0; }