#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

auto seed = chrono::high_resolution_clock().now().time_since_epoch().count();
mt19937 rnd(seed);

template<typename T>
using orderet_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename V>
using table = gp_hash_table<T, V>;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ld = long double;
using dd = double;

#define int ll

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

signed main(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    //cin>>t;
    while(t--) solve();
}