#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n, k, sum = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    sum += a[i];
  }
  sort(a, a + n);
  int res = a[n - 1];
  for (int t = n - k, i = n - k - 1; i >= 0; i--, t++) {
    if (res < a[i] + a[t]) {
      res = a[i] + a[t];
    }
  }
  if (k == 1)
    printf("%d\n", sum);
  else
    printf("%d\n", res);
  return 0;
}
