#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll l,x[225816],y[225816],z[225816];

int main(void){
	int n,i,p;
	ll ans,tmp;
	cin >> l >> n;
	x[0] = 0ll;
	y[0] = 0ll;
	x[n+1] = l;
	z[n+1] = 0ll;
	for(i=1; i<=n; ++i){
		cin >> x[i];
	}
	for(i=1; i<=n; ++i){
		y[i] = y[i-1] + x[i];
	}
	for(i=n; i>=1; --i){
		z[i] = z[i+1] + (l-x[i]);
	}
	ans = max(l-x[1],x[n]);
	for(i=1; i<=n; ++i){
		p = i+(n-i)/2;
		tmp = y[p]+z[p+1]-y[i-1];
		tmp *= 2;
		if((n-i)%2){
			tmp -= (l-x[p+1]);
		}else{
			tmp -= x[p];
		}
		ans = max(tmp,ans);
		p = i-(i-1)/2;
		tmp = z[p]+y[p-1]-z[i+1];
		tmp *= 2;
		if((i-1)%2){
			tmp -= x[p-1];
		}else{
			tmp -= (l-x[p]);
		}
		ans = max(tmp,ans);
	}
	cout << ans << endl;
	return 0;
}
