#include <bits/stdc++.h>
using namespace std;
int n, k, a[100005];
multiset<int> s;
bool check(int x) {
  for (int i = 0; i < n; i++) s.insert(a[i]);
  int sum = 0;
  while (!s.empty()) {
    int y = *s.begin();
    s.erase(s.begin());
    multiset<int>::iterator it = s.upper_bound(x - y);
    if (it != s.begin()) it--, s.erase(it);
    sum++;
  }
  if (sum <= k) return true;
  return false;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int lo = a[n - 1], hi = 10000000;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    if (check(mid))
      hi = mid - 1;
    else
      lo = mid + 1;
  }
  printf("%d\n", lo);
  return 0;
}
