#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <utility>
#include <memory.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define forkn(i, k, n) for (int i = k; i < (int)n; i++)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define sz(a) ((int)(a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <string> vs;
typedef pair <int,int> pii;
typedef pair <string,int> psi;
typedef map <string,int> msi;
template <class T> void relax(T &a, T b) { a = min(a, b); }
template <class T> void mrelax(T &a, T b) { a = max(a, b); }
const int N = 100010;
int n, k;
ll s[N];
bool can(ll x)
{
int cnt = 1, b = 0;
ll c = x;
forn(i, n)
{
if (x < s[n-i-1])
return false;
if (b == 2 || c < s[n-i-1])
c = x, cnt++, b = 0;
c -= s[n-i-1], ++b;
}
return cnt <= k;
}
int main()
{
/*
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/
cin >> n >> k;
forn(i, n) cin >> s[i];
ll l = s[n-1], r = l * n, m;
while (l < r)
{
m = (l + r) >> 1;
if (can(m))
r = m;
else
l = m + 1;
}
while (can(r)) --r;
cout << r + 1 << "\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxtZW1vcnkuaD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUg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