// Created by rost on 06.03.25.

#include <bits/stdc++.h>

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

const ll INF = (ll) 1e18 + 11;

const int MAX_N = 5e5;
int a[MAX_N];

int n;

pair<ll, int> solve(ll penalty) {
    vector<pair<ll, int>> dp(n);
    ll curMax = 0;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        dp[i] = {a[i] + (i + 1) - penalty + curMax, cnt + 1};

        if (dp[i].first - (i + 1) > curMax ||
            (dp[i].first - (i + 1) == curMax && dp[i].second < cnt)) {
            curMax = dp[i].first - (i + 1);
            cnt = dp[i].second;
        }
    }

    int resI = 0;
    for (int i = 0; i < n; ++i) {
        if (dp[i].first > dp[resI].first ||
            (dp[i].first == dp[resI].first && dp[i].second < dp[resI].second))
            resI = i;
    }
    return dp[resI];
}

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

#ifdef LOCAL
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
#endif

    int k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    vector<ll> dp((1 << n), -INF);
    dp[0] = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int subMask = mask; subMask > 0; subMask = (subMask - 1) & mask) {
            int j = 1, mx = 0;
            for (int i = 0; i < n; ++i) {
                if (subMask & (1 << i)) {
                    mx = max(mx, a[i] + j);
                    ++j;
                }
            }
            dp[mask] = max(dp[mask], dp[mask ^ subMask] + mx);
        }
    }
    cout << dp[(1 << n) - 1] << '\n';
}
