#include <bits/stdc++.h>
using namespace std;
typedef struct node {
  long long x;
  int y, cnt;
  node *l, *r;
  node(long long x) : x(x), y(rand() * rand()), cnt(1), l(NULL), r(NULL) {}
} * tree;
int CNT(tree t) { return t ? t->cnt : 0; }
void upd(tree t) {
  if (!t) return;
  t->cnt = CNT(t->l) + 1 + CNT(t->r);
}
void merge(tree &t, tree l, tree r) {
  if (!l || !r) {
    t = l ? l : r;
    return;
  }
  if (l->y > r->y) {
    merge(l->r, l->r, r);
    t = l;
  } else {
    merge(r->l, l, r->l);
    t = r;
  }
  upd(t);
}
void split(tree t, tree &l, tree &r, long long x) {
  if (!t) {
    l = r = NULL;
    return;
  }
  if (t->x <= x) {
    split(t->r, t->r, r, x);
    l = t;
  } else {
    split(t->l, l, t->l, x);
    r = t;
  }
  upd(t);
}
long long get(tree t, long long x) {
  if (!t) return 0;
  if (t->x <= x)
    return CNT(t->l) + 1 + get(t->r, x);
  else
    return get(t->l, x);
}
int a[100100];
int n;
long long s[100100];
tree tt[100100];
long long k;
tree base = new node(0);
bool enought(long long ans, long long k) {
  tree root = base, L, R;
  long long need;
  for (int(i) = 0; (i) < (n); ++(i)) {
    need = s[i] - ans;
    k -= get(root, need);
    split(root, L, R, s[i]);
    merge(root, L, tt[i]);
    merge(root, root, R);
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    tt[i]->l = tt[i]->r = NULL;
    tt[i]->cnt = 1;
  }
  base->l = base->r = NULL;
  base->cnt = 1;
  return k > 0;
}
long long bs(long long l, long long r) {
  long long mid, ans;
  while (l <= r) {
    mid = (l + r) / 2;
    if (enought(mid, k))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  return ans;
}
int main() {
  cin >> n >> k;
  for (int(i) = 0; (i) < (n); ++(i)) {
    scanf("%d", a + i);
    if (i)
      s[i] = s[i - 1] + a[i];
    else
      s[i] = a[i];
    tt[i] = new node(s[i]);
  }
  cout << bs(-1e14 - 1, 1e14 + 1) - 1 << endl;
  return 0;
}
