n, m = map(int, input().split()) a = [int(input()) for _ in range(n)] a0 = a[0] others = sorted(a[1:]) total_others = len(others) ans = -1 low = 0 high = total_others - 1 while low <= high: mid = (low + high) // 2 x = others[mid] # Create B by removing x at mid position B = others[:mid] + others[mid+1:] S = a0 + x cnt = 0 l = 0 r = len(B) - 1 while l < r: if B[l] + B[r] > S: cnt += 1 l += 1 r -= 1 else: l += 1 if cnt <= m - 1: ans = x high = mid - 1 else: low = mid + 1 print(ans if ans != -1 else -1)