#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 10, mod = int(1e9) + 7;
int n, qn;
long long k, p[N];
pair<long long, int> q[N];
long long t[2 * N];
void upd(int v) {
  v += qn;
  t[v]++;
  while (v > 1) {
    v >>= 1;
    t[v] = t[v + v] + t[v + v + 1];
  }
}
long long get(int l, int r) {
  l += qn;
  r += qn;
  long long res = 0;
  while (l <= r) {
    if (l & 1) res += t[l];
    if (!(r & 1)) res += t[r];
    l = (l + 1) >> 1;
    r = (r - 1) >> 1;
  }
  return res;
}
bool check(long long x) {
  int j = 1;
  long long res = 0;
  memset(t, 0, sizeof(t));
  for (int i = 1; i <= qn; i++) {
    while (j <= qn && q[i].first - q[j].first >= x) {
      upd(q[j].second);
      j++;
    }
    res += get(0, q[i].second - 1);
  }
  return (res >= k);
}
int main() {
  scanf("%d %lld", &n, &k);
  q[++qn] = make_pair(0, 0);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    p[i] = p[i - 1] + x;
    q[++qn] = make_pair(p[i], i);
  }
  sort(q + 1, q + qn + 1);
  long long l = -(long long)(1e14 + 1), r = (long long)1e14 + 1;
  while (r - l > 1) {
    long long m = (l + r) >> 1;
    if (check(m))
      l = m;
    else
      r = m;
  }
  printf("%lld", l);
  return 0;
}
