import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long m = sc.nextLong(); long A = sc.nextLong(); long[] a = new long[n - 1]; for(int i = 0; i < n - 1; i++) { a[i] = sc.nextLong(); } Arrays.sort(a); long l = 0; long r = n - 1; long ans = -1; while(l < r) { long med = (l + r) / 2; long t = A + a[(int)med]; long p = 0; int left = 0; int right = n - 2; while(left < right) { if(left == (int)med) { left++; } else if(right == (int)med) { right--; } else { long s = a[left] + a[right]; if(s > t) { p++; right--; left++; } else { left++; } } } if(p >= m) { l = med + 1; } else { ans = a[(int)med]; r = med; } } System.out.println(ans); } }