#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
long long setbits(long long x) { return __builtin_popcount(x); }
const long long MOD = 1e9 + 7;
const long long INF = 2e18;
long long mul(long long a, long long b) {
  if (a > INF / b)
    return INF;
  else
    return a * b;
}
long long n, k;
const long long N = 1e6 + 5;
long long a[N];
bool check(long long x) {
  long long num = 0;
  map<long long, long long> f;
  set<long long> y;
  for (long long i = 0; i < n; i++) {
    f[a[i]]++;
    y.insert(a[i]);
  }
  if (x < a[n - 1]) return false;
  for (long long i = n - 1; i >= 0; i--) {
    if (y.count(a[i])) {
      long long sec = x - a[i];
      f[a[i]]--;
      if (f[a[i]] == 0) y.erase(a[i]);
      auto it = y.lower_bound(sec);
      num++;
      if (y.empty()) continue;
      if (it == y.end()) it--;
      if (it == y.begin()) {
        if (*it <= sec) {
          f[*it]--;
          if (f[*it] == 0) y.erase(it);
        }
      } else if (it != y.begin()) {
        if (*it <= sec) {
          f[*it]--;
          if (f[*it] == 0) y.erase(it);
        } else {
          it--;
          f[*it]--;
          if (f[*it] == 0) y.erase(it);
        }
      }
    }
  }
  if (num <= k) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    cin >> n >> k;
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long lo = 0, hi = 2 * a[n - 1];
    while (lo < hi - 1) {
      long long mid = (lo + hi) / 2;
      if (check(mid))
        hi = mid;
      else
        lo = mid;
    }
    cout << hi;
  }
  return 0;
}
