#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
long long m;
pair<long long, int> v[100001];
int f[100002];
int x[100000];
int get(int x) {
  x++;
  int s = 0;
  while (x > 0) {
    s += f[x];
    x = (x & (x + 1)) - 1;
  }
  return s;
}
int add(int x) {
  x++;
  while (x <= n + 1) {
    f[x]++;
    x |= x + 1;
  }
  return 0;
}
long long calc(long long h) {
  if (h > 0) {
    memset(f, 0, sizeof(f));
    int k = n + 1;
    long long res = 0;
    for (int i = n; i >= 0; i--) {
      while (k - 1 > i && v[k - 1].first - v[i].first >= h) {
        k--;
        add(v[k].second);
      }
      res += get(v[i].second);
    }
    return res;
  } else {
    long long tmp = (long long)n * (n + 1) / 2;
    memset(f, 0, sizeof(f));
    int k = n + 1;
    long long res = 0;
    for (int i = n; i >= 0; i--) {
      while (k - 1 > i && v[k - 1].first - v[i].first > -h) {
        k--;
        add(n - v[k].second);
      }
      res += get(n - v[i].second);
    }
    return tmp - res;
  }
}
int main() {
  scanf("%d%I64d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  v[n] = make_pair(0, n);
  for (int i = n - 1; i >= 0; i--) v[i] = make_pair(v[i + 1].first + x[i], i);
  sort(v, v + n + 1);
  long long l = -1e18, r = 1e18;
  while (r - l > 1) {
    long long s = (l + r) / 2;
    if (calc(s) >= m)
      l = s;
    else
      r = s;
  }
  printf("%I64d\n", l);
  return 0;
}
