import sys n, m = map(int, input().split()) a0 = int(input()) a = [int(input()) for x in range(n - 1)] a.sort() #-1 check l = 0 r = n - 3 cnt = 0 while l < r: while l < r and a[l] + a[r] <= a[n - 2] + a0: l += 1 if l < r: l += 1 r -= 1 cnt += 1 if cnt >= m: print(-1) sys.exit(0) low = 0 high = n - 2 for i in range(50): mid = int((low + high) / 2) l = 0 r = n - 2 cnt=0 while l < mid and mid < r: while l < mid and a[l] + a[r] <= a[mid] + a0: l += 1 if la[mid]+a0: r -= 2 cnt += 1 while l+1a[mid]+a0: l+=2 cnt+=1 if cnt >= m: low = mid else: high = mid print(a[high])