#include #include using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; using ld = long double; using mint = modint998244353; // using mint = modint1000000007; constexpr ll INF = (1LL << 60); constexpr int INF32 = (1 << 30); template using vc = vector; template using vv = vector>; using vi = vc; using vvi = vv; using vl = vc; using vvl = vv; using vs = vc; using vvs = vv; using vb = vc; using vvb = vv; using vmint = vc; using vvmint = vv; using pii = pair; using pll = pair; #define rep(i,n) for(ll i=0; i<(ll)(n); i++) #define drep(i,n) for(ll i=(ll)(n)-1; i>=0; i--) #define rrep(i,n) for(ll i=1; i<=(ll)(n); i++) #define nfor(i,a,b) for(ll i=(ll)(a); i<(ll)(b); i++) #define dfor(i,a,b) for(ll i=(ll)(a)-1; i>=(ll)(b); i--) #define nall(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() template istream& operator>>(istream& is, vector& v) { for (auto& x : v) is >> x; return is; } template istream& operator>>(istream& is, pair& p) { return is >> p.first >> p.second; } template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; } void YES() { cout << "Yes\n"; } void NO() { cout << "No\n"; } void yn(bool ok) { cout << (ok ? "Yes" : "No") << '\n'; } template void print(const vector& v) { for (int i = 0; i < (int)v.size(); i++) { if (i) cout << ' '; cout << v[i]; } cout << '\n'; } template void print(const vector>& v) { for (const auto& row : v) { print(row); } } void print(ld x) { cout << fixed << setprecision(20) << x << '\n'; } int main() { int N, K; cin >> N >> K; vl A(N+1); rrep(i,N) cin >> A[i]; if((N+1)/2 < K) { cout << "Impossible" << endl; return 0; } vv dp(N+1,vvl(K+1,vl(2,-INF))); dp[0][0][0] = 0; rrep(i,N) { rep(j,K+1) { dp[i][j][0] = max(dp[i-1][j][0],dp[i-1][j][1]); if(j>0) dp[i][j][1] = dp[i-1][j-1][0] + A[i]; } } ll ans = max(dp[N][K][0],dp[N][K][1]); cout << ans << endl; }