#include<bits/stdc++.h>
#define mx 200005
using namespace std;

int n;
long long l, x[mx], ac1[mx], ac2[mx], ans;

int main(){
	scanf("%lld%d", &l, &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &x[i]);
		ac1[i] = ac1[i-1] + x[i];
	}
	for(int i = n; i > 0; i--) ac2[i] = ac2[i+1] + l - x[i];
	for(int i = 1; i <= n; i++){
		if(n != i){
			int k = min(n-i, i);
			long long a1 = (ac1[i] - ac1[i-k])*2 + (ac2[i+1] - ac2[i+1+k])*2 - min(x[i], (l - x[i+1]));
			ans = max(ans, a1);
		}
		int k2 = min(n-i, i-1);
		long long a2 = (ac1[i-1] - ac1[i-k2-1])*2 + (ac2[i+1] - ac2[i+1+k2])*2 + max(x[i], (l - x[i]));
		ans = max(ans, a2);
	}
	printf("%lld\n", ans);
}