#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define rep(i, n) for(int i=0; i<(n); ++i) #define FOR(i, m, n) for(int i=(m); i<(n); ++i) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define mp make_pair #define pb push_back #define Cout(x) cout << (x) << endl #define Cout2(x, y) cout << (x) << " " << (y) << endl #define dump(x) cerr << #x << " = " << (x) << endl; typedef long long LL; typedef vector VI; typedef vector VL; typedef vector VS; typedef vector VB; typedef vector> VVI; typedef pair PII; const int inf = 1e9; const double pi = acos(-1.0); int main() { LL n, m; cin >> n >> m; VL a(n); rep(i, n)cin >> a[i]; LL sum = 0, cnt = 0, i = 0; while (i < n) { if (a[i] % 2 == 1) { while (i < n&&a[i] % 2 == 1) { sum += a[i]; cnt++; i++; } if (cnt >= m)Cout(sum); } else { i++; cnt = 0; sum = 0; } } }