#include using namespace std; typedef unsigned long long ll; typedef std::pair P; #define frep(i, a, b) for(int i = (a); i < (b); i++) #define rep(i, n) frep(i, 0, (n)) #define rrep(i, n) for(int i = (n - 1); i >= 0; i--) #define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++) #define pb push_back const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const int MAX = 100010; const int INF = 1e9; const int MOD = 1000000007; const string END = "\n"; void solve(){ int n, m, a[MAX], ans; cin >> n >> m; rep(i, n) cin >> a[i]; sort(a, a + n); int left = 0, right = n; while(right - left > 1){ int mid = (right + left) / 2; int tmp = a[mid] + a[0]; int ll = 1, rr = n-1, cnt = 0; while(ll < rr){ if(ll == mid) ll += 1; else if(rr == mid) rr -= 1; else if(a[rr] + a[ll] >= tmp) ll += 1, rr -= 1, cnt += 1; else ll += 1; } if(cnt < m) right = mid; else left = mid; } if(right == n){ ans = -1; }else{ ans = a[right]; } cout << ans << END; } int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }