#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,sse4")
using namespace std;
void gogo() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int j = 0; j <= n - k; j++) {
        int sum = 0;
        for (int t = 1; t <= j; t++) {
            sum += a[t] + 1;
        }
        int mx = 0;
        for (int t = j + 1; t <= j + k; t++) {
            mx = max(mx, a[t] + t - j);
        }
        sum += mx;
        for (int t = j + k + 1; t <= n; t++) {
            sum += a[t] + 1;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        gogo();
    }
}

//25 62 100 69
//max 256