N, M = gets.split.map(&:to_i) A = N.times.map { gets.to_i } B = A[1..-1].sort.reverse def f(idx) x = A[0] + B[idx] left = 0 right = B.size - 1 cnt = 0 while left < right if left == idx left += 1 next elsif right == idx right -= 1 next end v = B[left] + B[right] if v <= x right -= 1 else cnt += 1 left += 1 right -= 1 end end cnt < M end if not f(0) puts -1 exit end if f(B.size - 1) puts B.last exit end ok = 0 ng = B.size - 1 while (ok - ng).abs >= 2 idx = (ok + ng) / 2 if f(idx) ok = idx else ng = idx end end puts B[ok]