#include using namespace std; typedef long long ll; typedef pair PII; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector a(n + 1); vector b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i].first; a[i].second = i; b[i] = a[i].first; } a[1] = {0, 1}; sort(a.begin() + 1, a.end(), [&](PII a, PII b){ if (a.first != b.first) return a.first > b.first; return a.second > b.second; }); ll sum = 0; set s; for (int i = 1; i <= k; i++) { sum += a[i].first; s.insert({a[i].second, a[i].first}); } int cur = k + 1; while (s.begin()->first % 2 != 0) { sum -= s.begin()->second; s.erase(s.begin()); sum += a[cur].first; s.insert({a[cur].second, a[cur].first}); cur++; } cout << sum << '\n'; return 0; }