#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll get(vector<ll>v, ll len)
{
	ll now = 0;
	int lb = 0, ub = v.size() - 1;
	for (int i = 0; i < v.size(); i++)
	{
		if (i % 2 == 0)
		{
			if (i == v.size() - 1)now += v[lb];
			else now += v[lb] * 2, lb++;
		}
		else
		{
			if (i == v.size() - 1)now += len - v[ub];
			else now += (len - v[ub]) * 2, ub--;
		}
	}
	ll maxi = now;
	int cur = v.size() % 2;
	for (int i = 0; i < v.size() - 1; i++)
	{
		now -= v[i] * 2;
		if (cur == 0)
		{
			now += v[lb] + v[lb] - len;
		}
		else
		{
			now += v[lb] + v[lb + 1] - len;
			lb++;
		}
		maxi = max(maxi, now);
		cur = 1 - cur;
	}
	return maxi;
}
int main()
{
	ll len;
	int num;
	scanf("%lld%d", &len, &num);
	vector<ll>v1, v2;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		v1.push_back(z);
		v2.push_back(len - z);
	}
	reverse(v2.begin(), v2.end());
	ll a = get(v1, len), b = get(v2, len);
	printf("%lld\n", max(a, b));
}
