#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

input = raw_input().split(" ")
N = int(input[0])
K = long(input[1])

aVec = raw_input().split(" ")
a = []

for i in aVec:
    a.append(long(i))


VecNum = N * (N + 1) / 2


subarray = []

for i in range(0, N):
    a_bubun = a[i:]
    for k in range(0, len(a_bubun)):
        subarray.append(a_bubun[k:])


#print subarray

beauty = []
for i in subarray:
    beauty.append(sum(i))
beauty.sort(reverse=True)


#K個大きい物を選ぶ
aK = []
for i in range(0, K):
    aK.append(beauty[i])


#論理積の最大値なので、最小値を求める
print min(aK)