#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
int n;
long long m;
const int MAXN = 111111;
long long a[MAXN], x[MAXN];
int xn;
int b[MAXN];
int cnt[MAXN];
void add(int u) {
  for (u++; u <= xn; u += u & -u) cnt[u]++;
}
int get(int u) {
  int ret = 0;
  for (; u; u -= u & -u) ret += cnt[u];
  return ret;
}
long long calc(long long mid) {
  memset(cnt, 0, sizeof(int) * (xn + 1));
  add(b[0]);
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    ret += get(upper_bound(x, x + xn, a[i] - mid) - x);
    add(b[i]);
    if (ret >= m) return ret;
  }
  return ret;
}
int main() {
  cin >> n >> m;
  x[xn++] = 0;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]), a[i] += a[i - 1], x[xn++] = a[i];
  sort(x, x + xn);
  xn = unique(x, x + xn) - x;
  for (int i = 0; i <= n; i++) b[i] = lower_bound(x, x + xn, a[i]) - x;
  long long lo = -(1LL << 50), hi = 1LL << 50;
  while (hi - lo > 1) {
    long long mid = lo + hi >> 1;
    if (calc(mid) < m)
      hi = mid;
    else
      lo = mid;
  }
  cout << lo << endl;
  return 0;
}
