import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; class Main { public static void main(String[] args) throws IOException { new Main().run(); } long INF = (long) (1e19); PrintWriter pw = new PrintWriter(System.out); void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); long a0 = -1; long[] a = new long[n - 1]; a0 = sc.nextLong(); for (int i = 0; i < n - 1; ++i) { a[i] = sc.nextLong(); } Arrays.sort(a); solve(a0, a, n, m); } void solve(long a0, long[] a, int n, int m) { int left = -1;// leftとペアを結んだとき商品は得られない場合が存在する。 int right = a.length;// rightとペアを結んだとき確実に商品が得られる。 while (right - left > 1) { int middle = (right + left) / 2; long sum = a0 + a[middle]; int s = 0; int cnt = 0; for (int i = a.length - 1; i >= 0 && s < i; --i) { while (s + 1 < i && a[i] + a[s] <= sum) { ++s; } if (a[i] + a[s] > sum) { ++cnt; ++s; } if (cnt == m) break; } if (cnt == m) { left = middle; } else { right = middle; } } if (right != a.length) { System.out.println(a[right]); } else { System.out.println(-1); } } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }