#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000LL;
const int maxn = 100010;
vector<long long> v;
long long s[maxn], a[maxn], c[maxn], K;
inline int lowbit(int x) { return x & (x ^ (x - 1)); }
void add(int x, int t, int n) {
  while (x <= n + 5) {
    c[x] += t;
    x += lowbit(x);
  }
}
long long query(int x) {
  long long sum = 0;
  while (x > 0) {
    sum += c[x];
    x -= lowbit(x);
  }
  return sum;
}
bool check(int n, long long key, long long k) {
  for (int i = 1; i <= n + 5; i++) c[i] = 0;
  add(lower_bound(v.begin(), v.end(), 0) - v.begin() + 1, 1, n);
  for (int i = 1; i <= n; i++) {
    k -= query(upper_bound(v.begin(), v.end(), s[i] - key) - v.begin());
    add(lower_bound(v.begin(), v.end(), s[i]) - v.begin() + 1, 1, n);
    if (k <= 0) return true;
  }
  return false;
}
int main() {
  int n, x;
  while (scanf("%d%I64d", &n, &K) != EOF) {
    s[0] = 0;
    v.clear();
    for (int i = 1; i <= n; i++) scanf("%d", &x), s[i] = s[i - 1] + x;
    for (int i = 0; i <= n; i++) v.push_back(s[i]);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    long long l = -INF, r = INF, mid, ans;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (check(n, mid, K))
        l = mid + 1, ans = mid;
      else
        r = mid - 1;
    }
    cout << ans << endl;
  }
  return 0;
}
