#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
template <class T>
class AVL {
 private:
  struct Node {
    T key;
    int height, size;
    Node *left, *right;
    Node() {
      left = right = NULL;
      height = size = 0;
    }
  };
  Node pool[110000];
  Node *NIL, *root;
  int base;
  Node *newNode(const T &_key) {
    Node *addr = &pool[base++];
    assert(110000 > base);
    addr->key = _key;
    addr->height = 1;
    addr->size = 1;
    addr->left = NIL;
    addr->right = NIL;
    return addr;
  }
  void updateHeightAndSize(Node *x) {
    x->height = max(x->left->height, x->right->height) + 1;
    x->size = x->left->size + x->right->size + 1;
  }
  void RightRotate(Node *&x) {
    Node *y = x->left;
    x->left = y->right;
    y->right = x;
    updateHeightAndSize(x);
    updateHeightAndSize(y);
    x = y;
  }
  void LeftRotate(Node *&x) {
    Node *y = x->right;
    x->right = y->left;
    y->left = x;
    updateHeightAndSize(x);
    updateHeightAndSize(y);
    x = y;
  }
  void balance(Node *&x) {
    updateHeightAndSize(x);
    if (x->left->height > x->right->height + 1) {
      Node *&y = x->left;
      if (y->right->height > y->left->height) {
        LeftRotate(y);
      }
      RightRotate(x);
    }
    if (x->right->height > x->left->height + 1) {
      Node *&y = x->right;
      if (y->left->height > y->right->height) {
        RightRotate(y);
      }
      LeftRotate(x);
    }
  }
  void AVL_insert(Node *&x, const T &key) {
    if (x == NIL) {
      x = newNode(key);
      return;
    }
    if (key < x->key)
      AVL_insert(x->left, key);
    else
      AVL_insert(x->right, key);
    balance(x);
  }
  T AVL_delete(Node *&x, const T &key) {
    T ret;
    if (key == x->key || (key < x->key && x->left == NIL) ||
        (key > x->key && x->right == NIL)) {
      ret = x->key;
      if (x->left == NIL || x->right == NIL) {
        x = (x->left != NIL) ? x->left : x->right;
        return ret;
      } else
        x->key = AVL_delete(x->left, key);
    } else {
      if (key < x->key)
        ret = AVL_delete(x->left, key);
      else
        ret = AVL_delete(x->right, key);
    }
    balance(x);
    return ret;
  }
  Node *find(Node *it, const T &_key) {
    if (it == NIL) {
      return NIL;
    }
    if (_key == it->key) {
      return it;
    }
    if (_key < it->key)
      return find(it->left, _key);
    else
      return find(it->right, _key);
  }
  int countLess(Node *node, const T &_key) {
    if (node == NIL) return 0;
    if (_key < node->key)
      return countLess(node->left, _key);
    else
      return node->left->size + 1 + countLess(node->right, _key);
  }

 public:
  AVL() { clear(); }
  void clear() {
    base = 0;
    root = NIL = &pool[base++];
  }
  int countLess(const T &_key) { return countLess(root, _key); }
  bool find(const T &_key) { return find(root, _key) != NIL; }
  bool insert(const T &key) {
    if (root == NIL) {
      root = newNode(key);
      return true;
    }
    AVL_insert(root, key);
    return true;
  }
  bool erase(const T &key) {
    if (!find(key)) {
      return false;
    } else {
      AVL_delete(root, key);
      return true;
    }
  }
};
AVL<long long> avl;
const int V = 110000;
long long sum[V];
int n;
long long m;
const long long INF = 1ll << 50;
bool debug = false;
long long count(long long mid) {
  avl.clear();
  long long ret = 0;
  avl.insert(0);
  for (int i = 0; i < n; ++i) {
    ret += avl.countLess(sum[i] - mid);
    avl.insert(sum[i]);
  }
  return ret;
}
int main() {
  int tmp;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    sum[i] = (i == 0) ? tmp : sum[i - 1] + tmp;
  }
  long long l = -INF, r = INF;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (count(mid) >= m) {
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << l - 1 << endl;
}
