#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

ll X,sum[2][200004];
int now = 0,rev = 1;

ll x(int now,int ind){
    if(ind==0){return sum[now][0];}
    return sum[now][ind]-sum[now][ind-1];
}

int main(){
    int N;
    ll L;
    cin>>L>>N;
    
    for(int i = 0;i < N;i++){
        cin>>X;
        sum[0][i]=X;
        sum[1][N-1-i]=L-X;}
    for(int i = 1;i < N;i++){
        sum[0][i]+=sum[0][i-1];
        sum[1][i]+=sum[1][i-1];
    }
    ll ans = 0;
    for(int xxxx = 0;xxxx < 2;xxxx++){
        for(int i = 0;i < N;i++){
            ll temp = 0;
            if((N-i)%2==1){
                int j = (N-1-i)/2;
                temp = 2*sum[rev][j-1]+2*sum[now][j+i]-x(now,j+i);
                if(i>0){temp -= 2*sum[now][i-1];}
            }else{
                int j = (N-i)/2;
                temp = 2*sum[rev][j-1]+2*sum[now][j+i-1]-x(rev,j-1);
                if(i>0){temp -= 2*sum[now][i-1];}
            }
            ans = max(ans,temp);
        }
        now = 1,rev = 0;
    }
    cout<<ans<<endl;
    
}
