#include <iostream>
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define st first
#define nd second

/**
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
**/

int a[500'500];

signed main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    int ans = 0;
    int mx = a[0];
    for (int i = 1; i < n; ++i)
    {
        ans = max(ans, mx + i + a[i]);
        mx = max(mx, a[i]);
    }

    cout << ans << '\n';
    return 0;
}
