#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <limits>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

#define Max(a, b) ((a) > (b) ? (a) : (b))
using namespace std;
using ll = long long;


int main(){
    int l,n;
    ll ans = 0,max_ = 0;
    cin >> l >> n;
    vector<int> X(n),rX(n);
    vector<ll> S(n),rS(n);
    rep(i,n) {
        cin >> X[i];
        S[i] = X[i];
        if(i>0) S[i] += S[i-1];
    }
    rep(i,n){
        rX[i] = l - X[n - i - 1];
        rS[i] = rX[i];
        if(i>0) rS[i] += rS[i-1];
    }
    if(n == 1){
        cout << Max(X[0],rX[0]) << endl;
        return 0;
    }

    if(n%2==0){
        rep(i,n-1){//ccw
            if(i % 2==0){
                if(i > 0)
                    max_ = Max(max_,2*(S[n - ceil((double)(n-i-1)/2) - 1] - S[i-1] + rS[floor((double)(n-i-1)/2)]) - rX[floor((double)(n-i-1)/2)]);
                else{
                    max_ = Max(max_, 2*(S[ceil(n/2)-1] + rS[floor(n/2)-1]) - rX[ceil(n/2)-1]);
                    // cout << "S:" << ceil(n/2)-1 << endl;
                    // cout << "rS:" << floor(n/2)-1 << endl;
                    // cout << "rX:" << ceil(n/2) - 1 << endl;
                    // cout << 2*(S[ceil(n/2)-1] + rS[floor(n/2)-1]) - X[ceil(n/2)-1] << endl;
                }
            }else{
                max_ = Max(max_, 2*(S[n - ceil((double)(n-i-1)/2) - 1] - S[i-1] + rS[floor((double)(n-i-1)/2) -1]) - X[n - ceil((double)(n-i-1)/2) - 1]);
            }
        }
        
        rep(i,n-1){//cw
            if(i % 2==0){
                if(i > 0)
                    max_ = Max(max_,2*(rS[n - ceil((double)(n-i-1)/2) - 1] - rS[i-1] + S[floor((double)(n-i-1)/2)]) - X[floor((double)(n-i-1)/2)]);
                else{
                    max_ = Max(max_, 2*(rS[ceil(n/2)-1] + S[floor(n/2)-1]) - X[ceil(n/2)-1]);
                    // cout << "S:" << ceil(n/2)-1 << endl;
                    // cout << "rS:" << floor(n/2)-1 << endl;
                    // cout << "X:" << ceil(n/2) - 1 << endl;
                    // cout << 2*(S[ceil(n/2)-1] + rS[floor(n/2)-1]) - rX[ceil(n/2)-1] << endl;
                }
            }else{
                max_ = Max(max_, 2*(rS[n - ceil((double)(n-i-1)/2) - 1] - rS[i-1] + S[floor((double)(n-i-1)/2) -1]) - rX[n - ceil((double)(n-i-1)/2) - 1]);
            }
        }
    }else{//n が奇数

        rep(i,n-1){//ccw
            if(i % 2==0){
                if(i > 0)
                    max_ = Max(max_, 2*(S[n - ceil((double)(n-i-1)/2) - 1] - S[i-1] + rS[floor((double)(n-i-1)/2)-1]) - X[n - ceil((double)(n-i-1)/2) - 1]);
                else{
                    max_ = Max(max_, 2*(S[ceil((double)n/2)-1] + rS[floor((double)n/2)-1]) - X[ceil((double)n/2)-1]);
                    // cout << "S:" <<  ceil(((double)n/2))-1 << endl;
                    // cout << "rS:" << floor(((double)n/2))-1 << endl;
                    // cout << "X:" <<  ceil(((double)n/2)) - 1 << endl;                
                    // cout << 2*(S[ceil((double)n/2)-1] + rS[floor((double)n/2)-1]) - X[ceil((double)n/2)-1] << endl;
                }
            }else{
                max_ = Max(max_, 2*(S[n - ceil((double)(n-i-1)/2) - 1] - S[i-1] + rS[floor((double)(n-i-1)/2)]) - rX[floor((double)(n-i-1)/2)] );
            }
        }

        rep(i,n-1){//cw
            if(i % 2==0){
                if(i > 0)
                    max_ = Max(max_,2*(rS[n - ceil((double)(n-i-1)/2) - 1] - rS[i-1] + S[floor((double)(n-i-1)/2)-1]) - rX[n-ceil((double)(n-i-1)/2)-1]);
                else{
                    max_ = Max(max_,2*(S[floor((double)n/2)-1] + rS[ceil((double)n/2)-1]) - rX[ceil((double)n/2)-1]);
                    // cout << "S:" <<  floor((double)n/2)-1 << endl;
                    // cout << "rS:" << ceil((double)n/2)-1 << endl;
                    // cout << "rX:" << ceil((double)n/2) - 1 << endl;
                    // cout << 2*(S[floor((double)n/2)-1] + rS[ceil((double)n/2)-1]) - rX[ceil((double)n/2)-1] << endl;
                }
            }else{
                max_ = Max(max_, 2*(rS[n - ceil((double)(n-i-1)/2) - 1] - rS[i-1] + S[floor((double)(n-i-1)/2)]) - X[floor((double)(n-i-1)/2)]);
                
            }
        }
    }

    cout << max_ << endl;
    return 0;
}

Measured memory_bytes: 4992