#include <bits/stdc++.h>
using namespace std;
int n, k, a[333333];
bool good(int second) {
  int l = 1, r = n, cnt = 0;
  while (l <= r) {
    cnt++;
    int t = second - a[r--];
    if (l > r) break;
    if (t >= a[l]) t -= a[l++];
  }
  if (cnt <= k)
    return 1;
  else
    return 0;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int l = a[n] - 1, r = 2 * a[n];
  while (r > l + 1) {
    int m = (r + l) / 2;
    if (good(m))
      r = m;
    else
      l = m;
  }
  cout << r;
  return 0;
}
