#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using sll = __int128;

template <typename T>
istream &operator>>(istream &in, pair<T, T> &a){
    in >> a.first >> a.second;
    return in;
}

template <typename T>
ostream &operator<<(ostream &out, pair<T, T> &a){
    out << a.first << ' ' << a.second;
    return out;
}

template <typename T>
istream &operator>>(istream &in, vector<T> &a){
    for(auto &x : a) in >> x;
    return in;
}

template <typename T>
ostream &operator<<(ostream &out, vector<T> &a){
    for(auto x : a) out << x << ' ';
    return out;
}

vector<vector<int>> g;
vector<int> d;

void dfs(int vi){
    for(auto to : g[vi]){
        d[to] = d[vi] + 1;
        dfs(to);
    }
}

int check(int x, vector<int> &s, int cancel){
    int main = 1;
    int cnt = 0;
    int prev = s[cancel];
    s[cancel] = 0;
    set<pair<int, int>> st;
    while(main != x){
        for(auto to : g[main]){
            st.insert({-s[to], to});
        }
        main = (*st.begin()).second;
        st.erase(st.begin());
        cnt++;
    }
    s[cancel] = prev;
    return cnt;
}

void solve(){
    int n, k;
    cin >> n >> k;
    ll a = 0, b = 0;
    ll ca = 0, cb = 0;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;
        if(a < b){
            a = max(a, x + ca + 1);
            ca++;
        } else {
            b = max(b, x + cb + 1);
            cb++;
        }
    }
    cout << a + b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1;
//    cin >> test;
    while(test--){
        solve();
    }
}

