#include #include using namespace std; using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i; using vvi = vector>; template inline void vin(vector& v) { rep(i, v.size()) cin >> v.at(i); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline void drop(T x) { cout << x << endl; exit(0); } template void vout(vector v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; using pint = pair; using vp = vector; int main() { lint N, K, no; cin >> N >> K >> no; vi v(N-1); vin(v); lint a=0, b=N-1, c=N-1, x, y, z; vp p(N-1); rep(i, N-1) p[i] = {v[i], -i}; sort(all(p), greater()); rep(i, K-1) { tie(x, y) = p[i]; y = -y; a += x; if (y%2 == 0) chmin(b, y); else chmin(c, y); } // list(a) // list(b) // list(c) x = 0; rep(i, N-1) { if (i%2 == 0 && i < min(b, c)) chmax(x, v[i]); else if (i > b && v[i] <= p[K-1].first) chmax(x, v[i]); } a += x; std::cout << a << '\n'; }