//ΔAGC030B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int l,n,a[N],b[N];
LL sa[N],sb[N],ans;
int main()
{
	int i,o;
	scanf("%d%d",&l,&n);
	for(i=1;i<=n;i=i+1)
		scanf("%d",a+i),b[i]=l-a[i];
	for(i=1;i<=n;i=i+1)
		sa[i]=sa[i-1]+a[i],sb[i]=sb[i-1]+b[i];
	ans=max(a[n],b[1]);
	for(i=1;i<n;i=i+1){
		if(i==n-i){
			ans=max(ans,(sa[i]+sb[n]-sb[i])*2-min(a[i],b[i+1]));
			continue;
		}
		if(i<n-i){
			o=i+i;
			ans=max(ans,(sa[i]+sb[o]-sb[i])*2+b[o+1]-min(a[o+1]-a[i+1],b[o+1]+a[i]));
		}
		else{
			o=i+i-n;
			ans=max(ans,(sa[i]-sa[o]+sb[n]-sb[i])*2+a[o]-min(a[i]-a[o],b[i+1]+a[o]));
		}
	}
	cout<<ans;
	return 0;
}