#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	ll l;
	int n;
	cin >> l >> n;
	vector<ll> xs(n);
	trav(x, xs) cin >> x;
	vector<ll> pre(n+1);
	rep(i,0,n) pre[i+1] = pre[i] + xs[i];
	vector<ll> erp(n+1);
	rrep(i,0,n) erp[i] = erp[i+1] + l-xs[i];

	ll ans = 0;

	rep(dif,-1,2){
		rep(m,0,n+1){
			int le = m, ri = n-m;
			ri = min(ri, le+dif);
			le = min(le, ri-dif);
			if(le+ri<=0) continue;

			ll cur = 0;
			cur += pre[m] - pre[m-le];
			cur += erp[m] - erp[m+ri];
			cur *= 2;
			if(dif==0) cur -= min(xs[m-1], l-xs[m]);
			else if(dif==1) cur -= l-xs[m];
			else cur -= xs[m-1];
			ans = max(ans, cur);
		}
	}
	cout << ans << endl;
}
