#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#include <complex>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
const int maxn = 2e5 + 5;
long long x[maxn];
long long q1[maxn], q2[maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	int l, n;
	cin >> l >> n;
	for(int i = 1; i <= n; i ++)
		cin >> x[i];
	for(int i = 1; i <= n; i ++)
		q1[i] = q1[i - 1] + x[i];
	for(int i = n; i >= 1; i --)
		q2[i] = q2[i + 1] + l - x[i];
	long long ans = 0;
	for(int i = 0; i <= n; i ++)
	{
		if(i == n - i)
			ans = max(ans, max(q1[i] * 2 - x[i] + q2[i + 1] * 2, q1[i] * 2 + q2[i + 1] * 2 - (l - x[i + 1])));
		else if(i > n - i)
			ans = max(ans, max((q1[i] - q1[2 * i - n - 1]) * 2 - x[i] + q2[i + 1] * 2, (q1[i] - q1[2 * i - n]) * 2 + q2[i + 1] * 2 - (l - x[i + 1])));
		else
			ans = max(ans, max(q1[i] * 2 + (q2[i + 1] - q2[2 * i + 2]) * 2 - (l - x[i + 1]), q1[i] * 2 - x[i] + (q2[i + 1] - q2[2 * i + 1]) * 2));
	}
	cout << ans << endl;
	
	return 0;
}