#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=200005;
#define ll long long
int l[N],r[N];
ll sl[N],sr[N];
inline int read(){
	int x=0;char e=getchar();
	for (;e<'0'||e>'9';e=getchar());
	for (;e>='0'&&e<='9';e=getchar()) x=(x<<1)+(x<<3)+(e^48);
	return x;
}
inline ll Max(ll a,ll b){return a>b?a:b;}
int main (){
	int len=read(),n=read();
	for (int i=1;i<=n;i++) l[i]=read();
	for (int i=1;i<=n;i++) r[i]=len-l[n+1-i];
	for (int i=1;i<=n;i++){
		sl[i]=sl[i-1]+l[i];
		sr[i]=sr[i-1]+r[i];
	}
	ll ans=0;
	for (int i=1;i<=n;i++){
		ll cur;
		int j=i+((n-i)>>1),k=(n-i+1)>>1;
		cur=(sl[j]-sl[i-1]+sr[k])<<1ll;
		if ((n-i)&1) cur-=r[k];else cur-=l[j]; 
		ans=Max(ans,cur);
		cur=(sr[j]-sr[i-1]+sl[k])<<1ll;
		if ((n-i)&1) cur-=l[k];else cur-=r[j]; 
		ans=Max(ans,cur);
	}
	printf ("%lld",ans);
	return 0;
} 