//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,bmi,bmi2,lzcnt,popcnt,tune=native")

/*
struct Update {
    int add = 0;
    Update() : add(0) {}
    Update(int add) : add(add) {}
    Update apply(Update other) {
        return add + other.add;
    }
};

struct Node {
    int summ = 0, l = 0, r = 0;
    Node() : summ(0), l(0), r(0) {}
    Node(int x) : summ(x) {}
    Node(int x, int l, int r) : summ(x), l(l), r(r) {}
    Node merge(Node other) {
        return Node(summ + other.summ, l, other.r);
    }
    Node apply(Update other) {
        return Node(summ + other.add * (r - l), l, r);
    }
};

struct seg_tree {
    int n;
    vector<int> a;
    vector<Node> tree;
    vector<Update> updates;

    seg_tree(vector<int> a2) {
        n = a2.size();
        a = a2;
        tree.resize(4 * n);
        updates.resize(4 * n);
        build(0, 0, n);
    }

    void push(int v) {
        if (updates[v].add != 0) {
            updates[2 * v + 1] = updates[2 * v + 1].apply(updates[v]);
            updates[2 * v + 2] = updates[2 * v + 2].apply(updates[v]);
            tree[2 * v + 1] = tree[2 * v + 1].apply(updates[v]);
            tree[2 * v + 2] = tree[2 * v + 2].apply(updates[v]);
            updates[v] = 0;
        }
    }

    void build(int v, int l, int r) {
        tree[v].l = l;
        tree[v].r = r;
        if (l == r - 1) {
            tree[v].summ = a[l];
            return;
        }
        int mid = (l + r) / 2;
        build(2 * v + 1, l, mid);
        build(2 * v + 2, mid, r);
        tree[v] = tree[2 * v + 1].merge(tree[2 * v + 2]);
    }

    Node get(int v, int l, int r, int ql, int qr) {
        if (ql <= l && r <= qr) {
            return tree[v];
        }
        if (qr <= l || r <= ql) {
            return Node();
        }
        push(v);
        int mid = (l + r) / 2;
        return get(2 * v + 1, l, mid, ql, qr).merge(get(2 * v + 2, mid, r, ql, qr));
    }


    Node get_q(int l, int r) {
        return get(0, 0, n, l, r);
    }


    void update(int v, int l, int r, int ql, int qr, Update add) {
        if (ql <= l && r <= qr) {
            tree[v] = tree[v].apply(add);
            updates[v] = updates[v].apply(add);
            return;
        }
        if (qr <= l || r <= ql) {
            return;
        }
        push(v);
        int mid = (l + r) / 2;
        update(2 * v + 1, l, mid, ql, qr, add);
        update(2 * v + 2, mid, r, ql, qr, add);
        tree[v] = tree[2 * v + 1].merge(tree[2 * v + 2]);
    }

    void update_q(int l, int r, int add) {
        update(0, 0, n, l, r, add);
    }
};

struct pt {
    int x, y;
    pt() : x(0), y(0) {}
    pt(int x, int y) : x(x), y(y) {}
    pt(pt s, pt t) : x(t.x - s.x), y(t.y - s.y) {}

    int operator*(pt other) {
        return x * other.y + y * other.x;
    }
    int operator%(pt other) {
        return x * other.y - y * other.x;
    }

    pt operator*(int k) {
        return pt(x * k, y * k);
    }

    pt operator+(pt other) {
        return pt(x + other.x, y + other.y);
    }

    pt operator-(pt other) {
        return pt(x - other.x, y - other.y);
    }
};

struct line {
    int a, b, c;
    line() : a(0), b(0), c(0) {}
    line(pt s, pt t) {
        a = t.y - s.y;
        b = s.x - t.x;
        c = -(t.y * s.x - t.x * s.y);
        //(t.y - s.y) * t.x + (s.x - t.x) * t.y = -s.y * t.x + s.x * t.y
        //(t.y - s.y) * s.x + (s.x - t.x) * s.y = t.y * s.x - t.x * s.y
    }

    bool is_on_line(pt other) {
        return other.x * a + other.y * b + c == 0;
    }
};*/


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (auto &i : a) {
        cin >> i;
    }
    long long mx = a[0], ans = 0;
    for (long long i = 1; i < n; i++) {
        ans = max(ans, a[i] + mx + i + 1);
        mx = max(mx, a[i]);
    }
    cout << ans << endl;
}

