import sys input = sys.stdin.readline def judge(x): p = a0+a[x] b = [a[i] for i in range(N-1) if i != x] pair = 0 l, r = 0, N-3 while l <= r: if b[l]+b[r] >= p+1: pair += 1 r -= 1 l += 1 return pair <= M-1 def binary_search(): left, right = 0, N-2 while left <= right: mid = (left+right)//2 if judge(mid): right = mid-1 else: left = mid+1 return left N, M = map(int, input().split()) a0 = int(input()) a = [int(input()) for _ in range(N-1)] a.sort() idx = binary_search() if idx == N-1: print(-1) else: print(a[idx])