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

long max_route(long x[], long l, long n) {
    long b[n];
    b[n - 1] = x[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        b[i] = b[i + 1] - x[n - 1 - ((n - 1 - i) >> 1)] + l - x[n - 1 - ((n - 2 - i) >> 1)] + (x[i] << 1);
    }
    return b[max_element(b, b + n) - b];
}

int main() {
    long l, n;
    cin >> l >> n;
    long x[n], x_rev[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        x_rev[n - i - 1] = l - x[i];
    }

    cout << max(max_route(x, l, n), max_route(x_rev, l, n)) << endl;
    return 0;
}
