#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll q = 1;
    while (q--) {
        solve();
    }
}

const ll INF = 1e18;

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll mx = -INF, ans = -INF;
    for (int i = n - 1; i > 0; i--) {
        mx = max(mx, a[i] + i + 1);
        ans = max(ans, mx + a[i - 1]);
    }
    cout << ans;
} 