#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n, k, ans;
int check(int val) {
  for (int i = 0; i < n; i++) {
    if (a[i] > val) return 0;
  }
  int st = 0, se = n - 1, sum = 0;
  while (st <= se) {
    if (a[st] + a[se] <= val) {
      st++;
      se--;
      sum++;
    } else {
      sum++;
      se--;
    }
  }
  if (sum <= k)
    return 1;
  else
    return 0;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  int l = a[0], r = 2000010, t;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      ans = mid;
      r = mid;
    } else
      l = mid + 1;
  }
  printf("%d\n", ans);
}
