#include <bits/stdc++.h>

using namespace std;
#define int long long
#define pb push_back


void solve () {
    int n,k;
    cin >> n >> k;
    vector < int > a(n);
    for (auto &i: a) {
        cin >> i;
    }
    int sum = -1e18;
    for (int mask = 0;mask < (1LL << n);mask++) {
        vector < int > c,b;
        for (int i = 0;i < n;i++) {
            if (((mask >> i) & 1LL)) {
                c.pb(a[i]);
            } else {
                b.pb(a[i]);
            }
        }
        int ans1 = -1e18,ans2 = -1e18;
        for (int i = 0;i < c.size();i++) {
            ans1 = max(c[i] + i + 1,ans1);
        }
        for (int i = 0;i < b.size();i++) {
            ans2 = max(b[i] + i + 1,ans2);
        }
        sum = max(sum,ans1 + ans2);
    }
    cout << sum << endl;
}
signed main () {
#ifdef LOCAL 
    freopen ("input.txt","r",stdin);
#endif
    solve();
    return 0;
}