#include <bits/stdc++.h>
using namespace std;
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
int readln() {
  int x;
  scanf("%d\n", &x);
  return x;
}
const int MAX_N = int(1e5) + 5;
int n;
long long a[MAX_N];
int f[MAX_N];
pair<long long, int> s[MAX_N];
void update(int i) {
  if (i < 1 || i > n) return;
  ++f[i];
  update(i + (i & (-i)));
}
int get(int i) {
  if (i < 1 || i > n) return 0;
  return f[i] + get(i - (i & (-i)));
}
long long cnt(long long limit) {
  long long ans = 0;
  memset(f, (0), sizeof(f));
  for (int i = 0, j = 0; i <= n; ++i) {
    while (j <= n && s[i].first - s[j].first >= limit) {
      update(s[j].second);
      ++j;
    }
    if (s[i].second) ans += get(s[i].second - 1) + (s[i].first - a[0] >= limit);
  }
  return ans;
}
int main() {
  n = read();
  long long k, l = 0, r = 0;
  cin >> k;
  s[0] = make_pair(0, 0);
  a[0] = 0;
  for (int i = 1; i <= n; ++i) {
    long long x = read();
    a[i] = a[i - 1] + x;
    s[i] = make_pair(a[i], i);
    if (x < 0)
      l += x;
    else
      r += x;
  }
  sort(s, s + 1 + n);
  long long ans = -1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (cnt(mid) >= k) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << ans << endl;
  return 0;
}
