#include<bits/stdc++.h>
#define int long long
using namespace std;

struct SegmentTree {
    int size;
    struct Node {
        int max;
        Node(int x) : max(x) {}
        Node() : max() {}
    };
    vector<Node> tree;
    SegmentTree(int n, vector<int> a) {
        size = 1;
        while (size <= n) size *= 2;
        tree.resize(size * 2 - 1);
        for (int i = size - 1; i < size * 2 - 1; i++) {
            int idx = i - (size - 1);
            if (idx <= n) {
                tree[i] = Node(a[idx]);
            } else {
                tree[i] = Node();
            }
        }
        for (int i = size - 2; i >= 0; i--) {
            tree[i] = merge(tree[i * 2 + 1], tree[i * 2 + 2]);
        }
    }
    Node merge(Node a, Node b) {
        Node node;
        node.max = max(a.max, b.max);
        return node;
    }
    Node get(int v, int lx, int rx, int l, int r) {
        if (rx <= l || r <= lx) {
            return Node();
        }
        if (lx <= l && r <= rx) {
            return tree[v];
        }
        int m = (l + r) >> 1;
        return merge(get(v * 2 + 1, lx, rx, l, m),
                     get(v * 2 + 2, lx, rx, m, r));
    }
    int get(int l, int r) {
        return get(0, l, r, 0, size).max;
    }
};

void XD_LMAO() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> pre(n);
    for (int i = 0; i < n; i++) {
        pre[i] = a[i] + i + 1;
    }
    SegmentTree tree(n, pre);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, tree.get(0, i + 1) + tree.get(i + 1, n) - i - 1);
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int test_ = 1;
    //cin >> test_;
    while (test_--) {
        XD_LMAO();
    }
    return 0;
}
