#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[200005], rev[200005], pre[200005], suf[200005];
int main()
{
	int len, n;
	scanf("%d%d", &len, &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", arr + i);
	}
	arr[++n] = len;
	for (int i = 0; i <= n; i++) {
		rev[n - i] = len - arr[i];
	}
	for (int i = 0; i <= n; i++) {
		pre[i] = (i ? pre[i - 1] : 0) + arr[i];
		suf[i] = (i ? suf[i - 1] : 0) + rev[i];
	}
	ll ans = 0;
	for (int i = 0, j = n - 1; i < n; i++, j--) {
		auto calc = [&] (int t) {
			ll res = pre[i] - (i >= t ? pre[i - t] : 0);
			res += suf[j] - (j >= t ? suf[j - t] : 0);
			return res << 1;
		};
		ans = max(ans, calc(min(i, j + 1)) - arr[i]);
		ans = max(ans, calc(min(i + 1, j)) - rev[j]);
	}
	printf("%lld\n", ans);
	return 0;
}
