local mfl, mce = math.floor, math.ceil local mmi, mma = math.min, math.max local bls, brs = bit.lshift, bit.rshift local n, m = io.read("*n", "*n") local a = io.read("*n") local t = {} n = n - 1 for i = 1, n do t[i] = io.read("*n") end table.sort(t) local function judge(x) local tgt = a + t[x] local z = {} for i = n, 1, -1 do if i ~= x then table.insert(z, i) end if 2 * m <= #z then break end end for i = 1, m do if t[z[i]] + t[z[2 * m + 1 - i]] <= tgt then return true end end return false end if m * 2 == n then print(t[1]) elseif not judge(n) then print(-1) elseif judge(1) then print(t[1]) else local min, max = 1, n while 1 < max - min do local mid = brs(min + max, 1) if judge(mid) then max = mid else min = mid end end print(t[max]) end