#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  int x = n * (n + 1) / 2;
  int l = 0, h = 0;
  long long int a[n], b[x];
  long long int sum = 0;
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      sum += a[j];
      b[l] = sum;
      l += 1;
    }
    sum = 0;
  }
  sort(b, b + x);
  cout << b[x - k] << endl;
  return 0;
}
