#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
int main() {
  long long int n, k, a[N], st, mx, j = 0;
  vector<int> v;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  mx = a[n - 1];
  if (n <= k) return cout << mx, 0;
  for (int i = n - k; i < n; i++) v.push_back(a[i]);
  for (int i = n - k - 1; i >= 0; i--, j++) {
    st = v[j] + a[i];
    mx = max(mx, st);
  }
  cout << mx;
}
