#include <bits/stdc++.h>
using namespace std;
long long const delta = 1000000007;
int main() {
  std::ios::sync_with_stdio(0);
  ;
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long l = 0, r = 0, mid;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    r += a[i];
    l = max(l, a[i]);
  }
  sort(a, a + n);
  r += 10;
  l = max(l - 5, (long long)0);
  long long ans = r;
  while (r - l > 1) {
    mid = l + ((r - l) / 2);
    long long t = 0;
    long long f = k;
    long long p = n;
    for (long long i = n - 1; i >= 0; i--) {
      if (t > i || a[i] > mid) break;
      if (t != i && a[i] + a[t] > mid) {
        f--;
        p--;
      } else if (t != i && a[i] + a[t] <= mid) {
        f--;
        t++;
        p -= 2;
      } else if (t == i) {
        f--;
        t++;
        p--;
      }
    }
    if (f >= 0 && !p) {
      r = mid;
      ans = min(ans, mid);
    } else {
      l = mid;
    }
  }
  cout << ans;
  return 0;
}
