#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if (y < x) x = y; } template static void amax(T &x, U y) { if (x < y) x = y; } int main() { int N; int M; while (~scanf("%d%d", &N, &M)) { int a0; scanf("%d", &a0); vector a(N - 1); for (int i = 0; i < N - 1; ++ i) scanf("%d", &a[i]); sort(a.begin(), a.end()); int lo = 0, up = N - 1; while (up - lo > 0) { int mid = (lo + up) / 2; int x = a0 + a[mid]; vector b = a; b.erase(b.begin() + mid); int num = 0; for (int i = (int)b.size() - 1, j = 0; i > j; -- i) { for (; j= M) lo = mid + 1; else up = mid; } printf("%d\n", up == N - 1 ? -1 : a[up]); } return 0; }