n,m = map(int,raw_input().split()) if not 2 <= n <= 100000: exit() if not n%2 == 0: exit() if not 1 <= m <= n/2: exit() x = input(); a = [] if not 1 <= x <= 1000000000: exit() def f(d): b = a[:d]+a[d+1:]; c = 0 i1 = 0; i2 = len(b)-1 while(i1a[d]+x: c+=1; i1+=1; i2-=1; else: i1+=1; return 1 if c < m else 0 for i in xrange(n-1): a.append(input()) for i in a: if not 1 <= i <= 1000000000: exit() a.sort() low = 0; high = len(a)-1 while(low < high): mid = (high+low)/2 if f(mid) == 1: high = mid else: low = mid+1 print a[low] if f(low) == 1 else -1