#include using namespace std; #define int long long signed main(){ cin.tie(0); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a.begin()+1,a.end()); if(n == m*2){ cout << a[1] << endl; return 0; } vector rival(m*2); for(int i = 0; i < n; i++){ if(i >= m*2) break; rival[i] = a[n-1 - i]; } int need = rival[0] + rival[m*2-1] - a[0]; for(int i = 1; i < n-m*2; i++){ if(a[i] >= need){ cout << a[i] << endl; return 0; } } cout << -1 << endl; return 0; }