#if __has_include() #include #else #include #include #endif using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define printYesNo(is_ok) puts(is_ok ? "Yes" : "No") #define SORT(v) sort(v.begin(), v.end()) #define RSORT(v) sort(v.rbegin(), v.rend()) #define REVERSE(v) reverse(v.begin(), v.end()) template void printVector(const Container &v, char delimiter = ' ') { for (auto itr = v.begin(); itr != v.end(); itr++) { if (itr != v.begin()) { cout << delimiter; } cout << *itr; } cout << endl; } template void printlnVector(const Container &v) { printVector(v, '\n'); } void solve() { long long N, K; cin >> N >> K; vector> dp(K + 1, vector(2, LONG_LONG_MIN)); dp[0][0] = 0; dp[0][1] = 0; rep(i, N) { long long A; cin >> A; vector> next_dp(K + 1, vector(2, LONG_LONG_MIN)); rep(k, K + 1) rep(pre, 2) rep(next, 2) { if (pre && next) { continue; } if (dp[k][pre] == LONG_LONG_MIN) { continue; } int next_k = k + next; if (K < next_k) { continue; } if (next) { next_dp[next_k][next] = max(next_dp[next_k][next], dp[k][pre] + A); } else { next_dp[next_k][next] = max(next_dp[next_k][next], dp[k][pre]); } } swap(dp, next_dp); } long long ans = max(dp[K][0], dp[K][1]); if (ans == LONG_LONG_MIN) { cout << "Impossible" << endl; } else { cout << ans << endl; } } int main() { int T = 1; // cin >> T; while (T--) { solve(); } return 0; }