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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=2e5+10, maxm=5e3+10, lg=31, mod=1e9+7, inf=1e18;

ll n,L,a[maxn],ps[maxn],ans;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>L>>n;
	for(int i=1;i<=n;i++) cin>>a[i], ps[i]=ps[i-1]+a[i];
	a[n+1]=L;
	for(int i=1,j;i<=n;i++){ j=n-i;
		ans=max({ans,j*L+2*(ps[i+j/2]-ps[i-1])-a[i+(j+1)/2]-2*(ps[n]-ps[i+(j+1)/2]),i*L+2*ps[(i-1)/2]+a[(i+1)/2]-2*(ps[i]-ps[i-(i+1)/2])});
	}
	cout<<ans;
	
	return 0;
}



