#include using namespace std; typedef long long ll; int main() { int N, M; cin >> N >> M; vector A(N); for (auto &a : A) cin >> a; A.push_back(0); ll cnt = 0, tot = 0; for (auto &a : A) { if (a & 1 == 1) { cnt++; tot += a; } else { if (cnt >= M) cout << tot << endl; cnt = 0; tot = 0; } } }