import java.util.*; import java.io.*; public class Main { static int[] dp; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int mm = Integer.parseInt(first[1]); int mine = Integer.parseInt(br.readLine()); int[] points = new int[n - 1]; for (int i = 0; i < n - 1; i++) { points[i] = Integer.parseInt(br.readLine()); } Arrays.sort(points); int left = 0; int right = n - 2; if (check(right, mine + points[right], points) >= mm) { System.out.println(-1); return; } if (check(left, mine + points[left], points) < mm) { System.out.println(points[left]); return; } while (right - left > 1) { int m = (left + right) / 2; if (check(m, mine + points[m], points) >= mm) { left = m; } else { right = m; } } System.out.println(points[right]); } static int check(int target, int score, int[] arr) { int left = 0; int right = arr.length - 1; int count = 0; while (left < right) { if (left == target) { left++; } else if(right == target) { right--; } else if (arr[left] + arr[right] <= score) { left++; } else { count++; left++; right--; } } return count; } }