#include <bits/stdc++.h>
using namespace std;
int n, tab[1000007];
long long k, suma[1000007];
long long wynik;
int d[300007];
map<long long, int> mapa;
inline static int zlicz(long long ile) {
  int x = mapa.upper_bound(ile)->second;
  long long y = mapa.upper_bound(ile)->first;
  x += 131072;
  int w = 0;
  while (x > 0) {
    if (x & 1) w += d[x - 1];
    x >>= 1;
  }
  return w;
}
inline static void wkladaj(long long ile) {
  int x = mapa[ile];
  x += 131072;
  while (x > 0) {
    d[x]++;
    x >>= 1;
  }
}
inline static long long sprawdz(long long ile) {
  memset(d, 0, sizeof(d));
  ;
  wkladaj(0);
  wynik = 0;
  for (int i = 1; i <= n; i++) {
    wynik += i - zlicz(suma[i] - ile - 1);
    wkladaj(suma[i]);
  }
  return wynik;
}
long long my_lbound(long long p, long long q) {
  long long s;
  while (p != q) {
    s = (p + q - ((p + q) < 0 ? 1 : 0)) / 2;
    if (sprawdz(s) <= k)
      p = s + 1;
    else
      q = s;
  }
  return p;
}
int main() {
  cin >> n >> k;
  k = ((long long)n) * (n + 1) / 2 - k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tab[i]);
    suma[i + 1] = suma[i] + tab[i];
    mapa[suma[i + 1]] = 1;
  }
  mapa[0] = 1;
  mapa[(long long)1000000007 * 1000000007] = 1;
  int nr = 1;
  for (typeof(mapa.begin()) it = mapa.begin(); it != mapa.end(); ++it) {
    it->second = nr;
    nr++;
  }
  cout << my_lbound((long long)-1000000007 * 100000,
                    (long long)1000000007 * 100000)
       << endl;
  return 0;
}
