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

int x[200010];
long long f[200010];
int L, n;

long long get_f(){
	long long res = x[n - 1];
	f[n - 1] = x[n - 1];
//	cout << f[n - 1] << " ";
	for (int i = n - 2; i >= 0; i--){
		int end = n - 1 - (n - 1 - i) / 2;
		f[i] = f[i + 1] + x[i] * 2 - x[end];
		if ((n - 1 - i) & 1) f[i] += L - x[end];
		else f[i] += L - x[end + 1]; 
		res = max(res, f[i]);
//		cout << f[i] << " ";
	}
//	cout << endl;
	return res;
}

int main(){
	scanf("%d%d", &L, &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	long long res = get_f();
	reverse(x, x + n);
	for (int i = 0; i < n; i++){
		x[i] = L - x[i];
	}
	printf("%lld\n", max(res, get_f()));
	return 0;
}
