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

const int MAX_N = 2e5 + 5;
lint l[MAX_N], r[MAX_N], sl[MAX_N], sr[MAX_N];


int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    lint L, N; cin >> L >> N;
    for(int i=1;i<=N;i++) cin >> l[i];

    for(int i=1;i<=N;i++) r[i] = L - l[N-i+1];

    for(int i=0;i<N;i++) sl[i+1] = sl[i] + l[i+1], sr[i+1] = sr[i] + r[i+1];

    lint ans = -1;
    for(int i=1;i<=N;i++){
        lint cur;
        // 反時計回り
        cur = 2 * (sl[i+(N-i)/2]-sl[i-1]+sr[(N-i+1)/2]);
        if((N-i)%2) cur -= r[(N-i+1)/2];
        else cur -= l[i+(N-i)/2];
        ans = max(ans, cur);

        // 時計回り
        cur = 2 * (sr[i+(N-i)/2]-sr[i-1]+sl[(N-i+1)/2]);
        if((N-i)%2) cur -= l[(N-i+1)/2];
        else cur -= r[i+(N-i)/2];
        ans = max(ans, cur);
    }

    cout << ans << endl;
    return 0;
}