#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define int ll

void solve() {

  int n,k; cin >> n >> k;
  int a[n]; for(int &i : a) cin >> i;
  
  int res = 0;
  int mx = a[0];
  for(int i = 1; i < n; ++i) {
    res = max(
      res,
      (i+1) + mx + a[i]
    );
    mx = max(mx, a[i]);
  }

  cout << res << '\n';

  return;
}


signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef pcms2
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
#endif
  // int tt; cin >> tt; while(tt--)
  solve();

  return 0;
}