#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> t;
vector<long long> b, a;
int n;
int get(long long val) {
  if (b[0] > val) return 0;
  int l = 0, r = b.size();
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (b[m] <= val)
      l = m;
    else
      r = m;
  }
  int res = 0;
  for (int i = l; i >= 0; i = (i & (i + 1)) - 1) res += t[i];
  return res;
}
void inc(long long val) {
  int l = 0, r = b.size();
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (b[m] <= val)
      l = m;
    else
      r = m;
  }
  for (int i = l; i < b.size(); i |= i + 1) t[i]++;
}
long long f(long long x) {
  t.assign(b.size(), 0);
  inc(0);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += get(a[i] - x);
    inc(a[i]);
  }
  return res;
}
int main() {
  long long k;
  scanf("%d%lld", &n, &k);
  a.resize(n);
  for (long long &i : a) scanf("%lld", &i);
  b.push_back(0);
  for (int i = 1; i < n; i++) a[i] += a[i - 1];
  for (long long i : a) b.push_back(i);
  sort(b.begin(), b.end());
  long long l = -1e14, r = 1e14;
  while (l + 1 < r) {
    long long m = (l + r) / 2;
    if (f(m) >= k)
      l = m;
    else
      r = m;
  }
  printf("%lld", l);
  return 0;
}
