#include <iostream>
#include <random>
#include <numeric>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll maxn = 3e5 + 10;
constexpr ll inf = 1e18;

ll n, k;
ll vals[maxn];
ll tv[maxn];
ll sfm[maxn], pfm[maxn];
//vector<ll> arrs[maxn];
//ll ans = 0;
//
//void rec_sol(ll level) {
//    if (level == n) {
//        for (ll i = 0; i < k; ++i) if (arrs[i].empty()) return;
//        ll cans = 0;
//        for (ll i = 0; i < k; ++i) {
//            ll cv = 0;
//            for (ll j = 0; j < arrs[i].size(); ++j) cv = max(cv, arrs[i][j] + j + 1);
//            cans += cv;
//        }
//        ans = max(ans, cans);
//        return;
//    }
//    for (ll i = 0; i < k; ++i) {
//        arrs[i].push_back(vals[level]);
//        rec_sol(level + 1);
//        arrs[i].pop_back();
//    }
//}

void solve() {
    cin >> n >> k;
    for (ll i = 0; i < n; ++i) cin >> vals[i];
    for (ll i = 0; i < n; ++i) tv[i] = vals[i] + i + 1;
    sfm[n] = 0;
    for (ll i = n - 1; i >= 0; --i) sfm[i] = std::max(sfm[i + 1], tv[i]);
    for (ll i = 0; i < n; ++i) pfm[i + 1] = std::max(pfm[i], vals[i]);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll cans = 0;
        if (i) cans = std::max(cans, tv[i] - 1 + pfm[i]);
        if (i + 1 < n) cans = std::max(cans, tv[i] + sfm[i + 1] - i - 1);
        ans = max(ans, cans);
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll t = 1;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> t;
#else
#ifdef TEST
    freopen("input.txt", "r", stdin);
#else
#endif
#endif
    while (t--) solve();
    return 0;
}
