//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#pragma GCC optimize("O3,Ofast,fast-math,unroll-loops")
#pragma GCC target("avx,avx2,fma,sse,sse2,sse3,sse4,sse4.1,sse4.2")

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long


//ordered_set
//ordered_set<int> A;
//A.find_by_order(1);
//A.order_of_key(1);

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int res = 0;
    int n, k;
    cin >> n >> k;
    vector<int> a;
    vector<int>b(n + 1);
    int x, lk=0;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        b[i] = x;
        if (i > 1 && b[i] > b[i - 1]) {
            return 12;
        }
        if (i>=k) {
            int cr = x+i+lk;
            res=max(res,cr);
        }
        lk+=x;
        if (i>=k) {
            lk -= b[i - k + 1];
        }
    }
    cout << res;
}
