import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 10L ^^ 16;

void main() {
    long L;
    int n;
    scan(L, n);
    auto x = iota(n).map!(i => readln.chomp.to!long).array;

    auto ans = max(solve(n, L, x), solve(n, L, x.map!(xi => L - xi).retro.array));

    writeln(ans);
}

long solve(int n, long L, long[] x) {
    auto y = x.map!(xi => L - xi).retro.array;

    auto xs = new long[](n + 1);
    foreach (i ; 0 .. n) {
        xs[i+1] = xs[i] + x[i];
    }

    auto ys = new long[](n + 1);
    foreach (i ; 0 .. n) {
        ys[i+1] = ys[i] + y[i];
    }

    debug {
        writeln("xs:", xs);
        writeln("y: ", y);
        writeln("ys:", ys);
    }

    long ans;

    foreach (i ; 1 .. n + 1) {
        int r = n - i;
        long tmp;

        if (i > r) {
            tmp = 2L * (xs[i] - xs[i - r - 1] + ys[r]) - x[i-1];
        }
        else {
            tmp = 2L * (xs[i] + ys[r] - ys[r - i]) - x[i-1];
        }

        debug {
            stderr.writefln("i: %d, tmp: %d", i, tmp);
        }

        ans = max(ans, tmp);
    }

    return ans;
}



























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}