#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = (int)1e9 + 7;
const int MAXN = (int)1e6 + 7;
int n;
int a[MAXN];
long long k;
long long second[MAXN];
vector<long long> t[MAXN];
void build(int v = 1, int tl = 1, int tr = n) {
  if (tl == tr)
    t[v].push_back(second[tl]);
  else {
    int mid = (tl + tr) / 2;
    build(v + v, tl, mid);
    build(v + v + 1, mid + 1, tr);
    t[v].resize(t[v + v].size() + t[v + v + 1].size());
    merge(t[v + v].begin(), t[v + v].end(), t[v + v + 1].begin(),
          t[v + v + 1].end(), t[v].begin());
  }
}
long long get(int l, int r, long long x, int v = 1, int tl = 1, int tr = n) {
  if (tl > r || tr < l) return 0;
  if (l <= tl && tr <= r)
    return upper_bound(t[v].begin(), t[v].end(), x) - t[v].begin();
  int mid = (tl + tr) / 2;
  return get(l, r, x, v + v, tl, mid) + get(l, r, x, v + v + 1, mid + 1, tr);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    second[i] = second[i - 1] + a[i];
  }
  build();
  long long ans = -100500;
  long long l = -(long long)1e18, r = (long long)1e18;
  while (l <= r) {
    long long mid = (l + r) / 2;
    long long total = 0;
    for (int i = 1; i <= n; i++) {
      total += get(1, i - 1, second[i] - mid);
      if (second[i] >= mid) total++;
    }
    if (total >= k) {
      ans = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << ans;
  return 0;
}
