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