#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt = 1; //cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

void solve() {
    int n, k; cin >> n >> k;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];

    vector<ll> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i - 1] + a[i] + 1;
        for (int j = 0; j < i; j++) {
            if (a[j] < a[i] + 1) dp[i] = max(dp[i], dp[j] + a[i] + 1 - a[j]);
        }
    }
    cout << dp[n];
}
