import strutils,sequtils,algorithm var L : seq[int] N,M,Ma,mi,n : int A,A2 : seq[int] k : int I,p,cnt,point,j,index : int A = @[] L = stdin.readline.split.map(parseInt) (N,M) = (L[0],L[1]) I = stdin.readline.parseInt for n in 0.. 0: n = (Ma + mi) div 2 p = A[n] point = I + p A2 = reversed(A[0..n-1] & A[n + 1..high(A)]) cnt = 0 block hantei: var right = A2.high for i,a in A2: for j in countdown(right,i): if j == i: break hantei if a + A2[j] > point: right = j - 1 cnt += 1 break if cnt >= M: mi = n + 1 if cnt < M: Ma = n if Ma <= N - 2 and A[mi] == A[Ma]: break if mi > N - 2: echo -1 else: echo A[mi]