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

int L, N, X[200000];
ll r[200001], l[200001], MAX;
int main()
{
	cin >> L >> N;
	for (int i = 0; i < N; ++i)
    {
        cin >> X[i];
    }
	for (int i = 0; i < N; ++i)
    {
        l[i + 1] = l[i] + X[i] * 2;
    }
	for (int i = N - 1; i >= 0; --i)
    {
        r[i] = r[i + 1] + (L - X[i]) * 2;
    }
	for (int i = 0; i < N; ++i)
    {
		ll cnt = X[i];
		if (i >= N - (i + 1))
		{
			cnt += r[i + 1];
			cnt += l[i] - l[i - (N - (i + 1))];
		}
		else
		{
			cnt += l[i];
			cnt += r[i + 1] - r[i + 1 + i + 1];
		}
		MAX = max(MAX, cnt);

		cnt = L - X[i];
		if (i <= N - (i + 1))
		{
			cnt += l[i];
			cnt += r[i + 1] - r[i + 1 + i];
		}
		else
		{
			cnt += r[i + 1];
			cnt += l[i] - l[i - (N - (i + 1)) - 1];
		}
		MAX = max(MAX, cnt);
	}

	cout << MAX << endl;

	return 0;
}
