#include <bits/stdc++.h>
using namespace std;
//Coded by Charlieyan
//版权所有，翻印必究

long long dp[200005];
int l,n;
int pos[200005];

int main(){
	scanf("%d%d",&l,&n);
	long long mx=0;
	for(int i=1;i<=n;i++){
		scanf("%d",pos+i);
	}
	for(int i=1;i<=n;i++){
		if(i%2){
			dp[i]=dp[i-1]+l-(pos[i/2+1]-pos[i/2])-2*(pos[i]-pos[i/2+1]);
		}else{
			dp[i]=dp[i-1]+l-2*(pos[i]-pos[i/2]);
		}
		//cerr<<i<<' '<<dp[i]<<endl;
	}
	for(int i=1;i<=n;i++){
		mx=max(mx,dp[i]);
	}
	reverse(pos+1,pos+n+1);
	for(int i=1;i<=n;i++){
		pos[i]=l-pos[i];
	}
	for(int i=1;i<=n;i++){
		if(i%2){
			dp[i]=dp[i-1]+l-(pos[i/2+1]-pos[i/2])-2*(pos[i]-pos[i/2+1]);
		}else{
			dp[i]=dp[i-1]+l-2*(pos[i]-pos[i/2]);
		}
		//cerr<<i<<' '<<dp[i]<<endl;
	}
	for(int i=1;i<=n;i++){
		mx=max(mx,dp[i]);
	}
	printf("%lld\n",mx);
	return 0;
}