#include <bits/stdc++.h>
int main(void) {
  int i, j, tmp;
  int number[1000];
  int N;
  scanf("%d", &N);
  int s, K, total;
  scanf("%d", &K);
  printf("%d個の数値を入力 \n", N);
  for (i = 0; i < N; ++i) scanf("%d", &number[i]);
  for (i = 0; i < N; ++i) {
    for (j = i + 1; j < N; ++j) {
      if (K > number[i] > number[j]) {
        tmp = number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }
  for (s = 0; s < K; ++i) {
    total = number[s] + number[s + 1];
  }
  printf("%d", total);
}
