#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const long long inf = 1000000000000000LL;
struct node {
  int left, right, aux, cnt, size;
  long long key;
} tree[maxn];
int tot;
inline void init() {
  tot = 0;
  tree[0].left = tree[0].right = tree[0].cnt = tree[0].size = 0;
  tree[0].aux = (RAND_MAX << 14) + RAND_MAX + 1;
}
inline void renew(int &root) {
  tree[root].size =
      tree[root].cnt + tree[tree[root].left].size + tree[tree[root].right].size;
}
inline void leftRotate(int &root) {
  int t = tree[root].left;
  tree[root].left = tree[t].right;
  tree[t].right = root;
  renew(root);
  renew(t);
  root = t;
}
inline void rightRotate(int &root) {
  int t = tree[root].right;
  tree[root].right = tree[t].left;
  tree[t].left = root;
  renew(root);
  renew(t);
  root = t;
}
inline void insert(int &root, long long key) {
  if (root == 0) {
    root = ++tot;
    tree[root].left = tree[root].right = 0;
    tree[root].cnt = tree[root].size = 1;
    tree[root].key = key;
    tree[root].aux = (rand() << 14) + rand();
    return;
  }
  if (tree[root].key == key) {
    ++tree[root].cnt;
  } else if (key < tree[root].key) {
    insert(tree[root].left, key);
    if (tree[tree[root].left].aux < tree[root].aux) leftRotate(root);
  } else {
    insert(tree[root].right, key);
    if (tree[tree[root].right].aux < tree[root].aux) rightRotate(root);
  }
  renew(root);
}
inline void insert_norepeat(int &root, long long key) {
  if (root == 0) {
    root = ++tot;
    tree[root].left = tree[root].right = 0;
    tree[root].cnt = tree[root].size = 1;
    tree[root].key = key;
    tree[root].aux = (rand() << 14) + rand();
    return;
  }
  if (tree[root].key == key) {
  } else if (key < tree[root].key) {
    insert_norepeat(tree[root].left, key);
    if (tree[tree[root].left].aux < tree[root].aux) leftRotate(root);
  } else {
    insert_norepeat(tree[root].right, key);
    if (tree[tree[root].right].aux < tree[root].aux) rightRotate(root);
  }
  renew(root);
}
inline void erase(int &root) { root = 0; }
inline void erase(int &root, long long key) {
  if (root == 0) return;
  if (tree[root].key != key)
    erase(key < tree[root].key ? tree[root].left : tree[root].right, key);
  else {
    if (!(tree[root].left) && !(tree[root].right))
      erase(root);
    else {
      if (tree[tree[root].left].aux < tree[tree[root].right].aux)
        leftRotate(root);
      else
        rightRotate(root);
      erase(root, key);
    }
  }
  renew(root);
}
inline int getNum(int &root, long long key) {
  if (root == 0) return 0;
  if (tree[root].key > key) return getNum(tree[root].left, key);
  return tree[root].cnt + tree[tree[root].left].size +
         getNum(tree[root].right, key);
}
inline long long kth(int &root, int k) {
  if (tree[root].size < k) return -1;
  int act = tree[tree[root].left].size + 1;
  if (act == k) return tree[root].key;
  if (act > k)
    return kth(tree[root].left, k);
  else
    return kth(tree[root].right, k - act);
}
void showtree(int root) {
  if (root == 0) return;
  cout << "root"
       << " = " << root << "  "
       << "tree[root].key"
       << " = " << tree[root].key << endl;
  ;
  cout << "\"left \""
       << " = "
       << "left "
       << "  "
       << "(tree[root].key)"
       << " = " << (tree[root].key) << endl;
  ;
  showtree(tree[root].left);
  cout << "\"right \""
       << " = "
       << "right "
       << "  "
       << "(tree[root].key)"
       << " = " << (tree[root].key) << endl;
  ;
  showtree(tree[root].right);
}
long long A[maxn];
int n;
bool calc(long long val, long long k) {
  init();
  int root = 0;
  long long cnt = 0;
  insert(root, 0);
  for (int i = 0; i < n; ++i) {
    cnt += getNum(root, A[i] - val);
    insert(root, A[i]);
  }
  return cnt >= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long k;
  cin >> n >> k;
  long long maxi = 0;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    maxi += abs(A[i]);
    if (i) A[i] += A[i - 1];
  }
  long long l = -maxi, r = maxi + 1, mid;
  while (l + 1 < r) {
    mid = (l + r) / 2;
    if (calc(mid, k))
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
  return 0;
}
