#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll ku[214514];
ll l,n;
ll ksum(ll st, ll en){
	if(st>=n)return 0;
	if(en<0)return 0;
	if(en<st)return 0;
	if(st==0)return ku[en];
	return ku[en]-ku[st-1];
}
int main(){
	vector<ll> x;
	cin>>l>>n;
	for(ll i=0;i<n;i++){
		ll tmp;
		cin>>tmp;
		x.pb(tmp);
		if(i==0)ku[0]=x[0];
		else ku[i]=ku[i-1]+x[i];
	}
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ll cur=0;
		ll cn = min(i, n-1-i);
		cur += l-x[i];
		cur += 2 * ksum(max(i-cn-1,(ll)0), i-1);
		cur += 2 * (cn*l - ksum(i+1,i+cn));
		if(cur>ans){ans=cur;}
		//cout<<i<<1<<cur<<endl;
		cur=0;
		cur += x[i];
		cur += 2 * ksum(i-cn, i-1);
		cur += 2 * ((l*(min(i+cn+1,n-1)-i)) - ksum(i+1,min(i+cn+1,n-1)));
		if(cur>ans){ans=cur;}
		//cout<<i<<2<<cur<<endl;
		cur=0;
		cur += max(x[i], l-x[i]);
		cur += 2 * ksum(i-cn, i-1);
		cur += 2 * (cn*l - ksum(i+1,i+cn));
		//cout<<i<<3<<cur<<endl;
		if(cur>ans){ans=cur;}
	}
	cout<<ans<<endl;
	return 0;
}