#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int n;
long long k;
long long arr[MAX], prefix[MAX], bit[MAX];
void update(int x) {
  for (int i = x; i <= n; i += i & -i) bit[i]++;
}
int query(int x) {
  int res = 0;
  for (int i = x; i; i -= i & -i) res += bit[i];
  return res;
}
long long solve(long long x) {
  for (int i = 1; i <= n; i++) bit[i] = 0;
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    int idx = upper_bound(prefix + 1, prefix + 1 + n, arr[i] - x) - prefix - 1;
    res += query(idx) + (arr[i] >= x);
    idx = lower_bound(prefix + 1, prefix + 1 + n, arr[i]) - prefix;
    update(idx);
  }
  return res;
}
int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", arr + i);
    arr[i] += arr[i - 1];
    prefix[i] = arr[i];
  }
  sort(prefix + 1, prefix + 1 + n);
  long long l = -1e14, r = 1e14, ans = -1e14;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (solve(mid) >= k) {
      l = mid + 1;
      ans = mid;
    } else
      r = mid - 1;
  }
  printf("%lld\n", ans);
}
