#include <bits/stdc++.h>
using namespace std;
const int Max = 100005;
const int Mod = 1000000007;
const long long llinf = 1000000000000000007;
long long k;
int n, Cmo;
long long sum[Max];
set<long long> s;
int a[Max], T[Max];
map<long long, int> Map;
void Upd(int x) {
  for (x; x <= Cmo; x += x & -x) T[x]++;
}
int Sum(int x) {
  int res = 0;
  for (x; x >= 1; x -= x & -x) res += T[x];
  return res;
}
bool Solution(long long x) {
  long long ans = 0;
  Upd(Map[0]);
  for (int i = 1; i <= n; i++) {
    ans += Sum(Map[*--s.upper_bound(sum[i] - x)]);
    Upd(Map[sum[i]]);
  }
  return (ans >= k);
}
int main() {
  scanf("%d%I64d", &n, &k);
  Map[0] = 1;
  s.insert(0);
  s.insert(llinf);
  s.insert(-llinf);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = a[i] + sum[i - 1];
    Map[sum[i]] = 1;
    s.insert(sum[i]);
  }
  Cmo = 2;
  for (auto i : Map) Map[i.first] = Cmo++;
  long long mn = -llinf;
  long long mx = llinf;
  while (mn + 1 < mx) {
    long long Nah = (mn + mx) / 2;
    if (Solution(Nah))
      mn = Nah;
    else
      mx = Nah;
    memset(T, 0, sizeof(T));
  }
  cout << mn;
}
