#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int maxn=2e5+5;
ll l;
ll a[maxn];
ll pre[maxn];
ll suf[maxn];
ll ans;
inline ll solve(){
	memset(pre,0,sizeof(pre));
	memset(suf,0,sizeof(suf));
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	for(int i=n;i>=1;i--) suf[i]=suf[i+1]+l-a[i]; 
	ll ans=a[n];
	for(int i=1;i<=n;i++){
		int tmp=i+((n-i)>>1);
		if((n-i)&1) ans=max(ans,(suf[tmp+2]+pre[tmp]-pre[i]+a[i])*2+l-a[tmp+1]);
		else ans=max(ans,(suf[tmp+1]+pre[tmp-1]-pre[i]+a[i])*2+a[tmp]) ;
	}
	return ans;
}
int main(){
	scanf("%lld%d",&l,&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	ll ans=solve();
	reverse(a+1,a+1+n);
	for(int i=1;i<=n;i++) a[i]=l-a[i];
	ans=max(ans,solve());
	printf("%lld\n",ans);
	return 0;
}