#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
const long long inf = 1e14 + 5;
long long arr[M], ps[M], k;
int a[M], ptr = 1, b[M], fen[M];
int32_t main() {
  int n;
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    scanf("%d", a + i), ps[i] = ps[i - 1] + a[i], arr[ptr++] = ps[i];
  sort(arr, arr + ptr);
  ptr = unique(arr, arr + ptr) - arr;
  for (int i = 0; i <= n; i++)
    b[i] = lower_bound(arr, arr + ptr, ps[i]) - arr + 1;
  long long lo = -inf, hi = inf;
  while (hi - lo > 1) {
    long long mid = (hi + lo) / 2ll;
    memset(fen, 0, sizeof fen);
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
      long long dis = ps[i] - mid;
      int p = upper_bound(arr, arr + ptr, dis) - arr, q = b[i];
      for (; p; p -= p & -p) ans += fen[p];
      for (; q < M; q += q & -q) fen[q]++;
    }
    ans >= k ? lo = mid : hi = mid;
  }
  return cout << lo << endl, 0;
}
