#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  int j = v.size() - 1, times = k;
  vector<int> ans(k);
  while (1) {
    ans[times - 1] = v[j];
    times--;
    j--;
    if (times <= 0 || j < 0) break;
  }
  int diff = v.size() - k;
  if (diff > 0) {
    vector<int> last;
    for (int i = 0; i < diff; i++) {
      last.push_back(v[i]);
    }
    sort(last.rbegin(), last.rend());
    int ct = 0;
    while (diff--) {
      ans[ct] += last[ct];
      ct++;
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.back() << endl;
  return 0;
}
