#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int ar[maxn];
int s[maxn];
int n, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> ar[i];
    s[i] = -ar[i];
  }
  sort(ar, ar + n);
  sort(s, s + n);
  int i = n - 1;
  int j = 0;
  while (i >= k) {
    ar[j] += ar[i];
    ++j;
    --i;
  }
  i = k;
  j = k - 1;
  while (j + 1) {
    s[j] += s[i];
    ++i;
    --j;
  }
  int ans1 = -INT_MAX;
  for (int i = 0; i < k; ++i) ans1 = max(ans1, ar[i]);
  int ans2 = -INT_MAX;
  for (int i = 0; i < k; ++i) {
    ans2 = max(ans2, -s[i]);
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}
