#include<iostream>
#include<algorithm>
using namespace std;
long X,L[2<<17],R[2<<17],ans;
long Ls[2<<17],Rs[2<<17];
int n;
long Lsum(int id,int c)
{
	return Ls[id+1]-Ls[id+1-c];
}
long Rsum(int id,int c)
{
	return Rs[id+1]-Rs[id+1-c];
}
int main()
{
	cin>>X>>n;
	for(int i=0;i<n;i++)
	{
		cin>>L[i];
		R[n-i-1]=X-L[i];
	}
	for(int i=0;i<n;i++)Ls[i+1]=Ls[i]+L[i],Rs[i+1]=Rs[i]+R[i];
	for(int i=0;i<n;i++)
	{
		long now=L[i];
		int cnt=min(i,n-i-1);
		now+=Lsum(i-1,cnt)*2+Rsum(n-i-2,cnt+(i<n-i-1))*2;
		ans=max(ans,now);
		now=X-L[i];
		now+=Lsum(i-1,cnt+(i>n-i-1))*2+Rsum(n-i-2,cnt)*2;
		ans=max(ans,now);
	}
	cout<<ans<<endl;
}
