#include <bits/stdc++.h>

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;

ll slow(int l, vector<int> a) {
    a.insert(a.begin(), 0);
    a.push_back(l);

    int n = a.size();
    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(n, vector<ll>(2, -1)));
    dp[0][n - 1][0] = 0;

    for (int cnt = 0; cnt < n - 2; cnt++) {
        for (int i = 0; i <= cnt; i++) {
            int j = cnt - i;
            j = n - 1 - j;

            ll len = a[i] + (l - a[j]);
            for (int f = 0; f < 2; f++) {
                if (dp[i][j][f] < 0) continue;
                ll cur = dp[i][j][f];

                {
                    ll ncur = cur + a[i + 1] - a[i];
                    if (f != 0) ncur += len;
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], ncur);
                }
                {
                    ll ncur = cur + a[j] - a[j - 1];
                    if (f != 1) ncur += len;
                    dp[i][j - 1][1] = max(dp[i][j - 1][1], ncur);
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int f = 0; f < 2; f++) {
            ans = max(ans, dp[i][i + 1][f]);
        }
    }
    return ans;
}

struct Sum {
    int n;
    vector<int> a;
    vector<ll> s;

    Sum(vector<int> _a) {
        a = _a;
        n = a.size();
        s.assign(n + 1, 0);
        for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
    }

    ll get(int l, int r) {
        if (l > r) return 0;
        return s[r + 1] - s[l];
    }
};

ll solve(int l, vector<int> a) {
    int n = a.size();

    ll ans = 0;

    for (int it = 0; it < 2; it++) {
        vector<int> b(n);
        for (int i = 0; i < n; i++) b[i] = l - a[i];

        Sum sa(a), sb(b);

        for (int i = 0; i <= n; i++) {
            int j = n - i;

            for (int f = 0; f < 2; f++) {
                if (f == 0 && i == 0 || f == 1 && j == 0) continue;

                int ci = i - (f == 0);
                int cj = j - (f == 1);

                int cnti = min(ci, j);
                int cntj = min(i, cj);


                ll cans = 0;
                if (f == 0) {
                    cans += a[i - 1];
                    cans += sa.get(i-2 - cnti+1, i-2) * 2;
                    cans += sb.get(i, i + cntj-1) * 2;
                } else {
                    cans += b[i];
                    cans += sa.get(i-1 - cnti+1, i-1) * 2;
                    cans += sb.get(i+1, i+1 + cntj-1) * 2;
                }
                ans = max(ans, cans);
            }
        }

        reverse(a.begin(), a.end());
        for (int &x : a) x = l - x;
    }
    return ans;
}

void stress() {
    for (int it = 0;; it++) {
        cout << it << endl;
        srand(it);

        int l = rand() % 100 + 3;
        int n = rand() % (l - 2) + 1;
        set<int> st;
        while (st.size() < n) st.insert(rand() % (l - 2) + 1);

        vector<int> a(st.begin(), st.end());
        auto ans1 = slow(l, a);
        auto ans2 = solve(l, a);
        assert(ans1 == ans2);
    }
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif
    //stress();

    int l, n;
    while (scanf("%d%d", &l, &n) == 2) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);

        printf("%lld\n", solve(l, a));
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 8088