#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, L;
	cin >> L >> N;
	vector<int> X(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
	}
	vector<long long> S(N + 1);
	for (int i = 0; i < N; ++i) {
		S[i + 1] = S[i] + X[i];
	}
	long long ans = 0;
	for (int i = 0; i <= N; ++i) {
		// cut to [0, i) and [i, N)
		// left-ending
		if (i >= 1) {
			int al = min(i, N - i + 1);
			int ar = min(i, N - i);
			long long as = -X[i - 1];
			as += (S[i] - S[i - al]) * 2;
			as += (1LL * L * ar - (S[i + ar] - S[i])) * 2;
			ans = max(ans, as);
		}
		if (i <= N - 1) {
			int al = min(N - i, i + 1);
			int ar = min(N - i, i);
			long long as = -(L - X[i]);
			as += (S[i] - S[i - ar]) * 2;
			as += (1LL * L * al - (S[i + al] - S[i])) * 2;
			ans = max(ans, as);
		}
	}
	cout << ans << endl;
	return 0;
}