#include <bits/stdc++.h>
using namespace std;
const int maxn = 100020;
const int maxx = 10000;
const int MOd = 1e9 + 7;
const int K = 750;
long long b;
int a, ar[maxn], fw[maxn];
void update(int k) {
  for (int i = k; i <= a + 1; i += i & (-i)) fw[i]++;
}
int find(int k) {
  int ret = 0;
  for (int i = k; i > 0; i -= i & (-i)) ret += fw[i];
  return ret;
}
long long f(long long n) {
  long long t = 0;
  long long ret = 0;
  vector<pair<long long, int> > w;
  memset(fw, 0, sizeof(fw));
  w.push_back(pair<long long, int>(0, 1));
  for (int i = 1; i <= a; i++) {
    t += ar[i];
    w.push_back(pair<long long, int>(t, (i + 1)));
    w.push_back(pair<long long, int>(t - n, -(i + 1)));
  }
  sort(w.begin(), w.end());
  for (int i = w.size() - 1; i >= 0; i--) {
    if (w[i].second < 0)
      ret += find(-w[i].second);
    else
      update(w[i].second);
  }
  if (n >= 0) ret -= a;
  return ret;
}
int main() {
  scanf("%d", &a);
  cin >> b;
  b = (long long)a * (a + 1) / 2 - b + 1;
  for (int i = 1; i <= a; i++) scanf("%d", &ar[i]);
  long long t = -1e14;
  for (int k = 50; k >= 0; k--)
    if (f(t + (1ll << k)) < b) t += (1ll << k);
  t++;
  cout << t << endl;
  return 0;
}
