#include using namespace std; int main(){ int N, K; cin >> N >> K; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } priority_queue, greater> pq; long long ans = 0; long long sum = 0; for (int i = N - 1; i >= 0; i--){ if (i % 2 == 1){ ans = max(ans, sum + A[i]); } pq.push(A[i]); sum += A[i]; if (pq.size() >= K){ sum -= pq.top(); pq.pop(); } } cout << ans << endl; }