#include <bits/stdc++.h>

using namespace std;

int n, L, a[200005], b[200005];
long long ans, sa[200005], sb[200005];

long long qsuma(int l, int r) {
	return sa[r] - sa[l - 1];
}

long long qsumb(int l, int r) {
	return sb[r] - sb[l - 1];
}

void solve() {
	for (int i = n; i; --i) {
		int bl = (n - i) / 2, al = n - i - bl;
		ans = max(ans, ((n - i & 1) ? b[n - bl] : a[n - al]) + (qsumb(n - bl + 1, n) + qsuma(i, i + al - 1)) * 2);
	}
}

int main() {
	scanf("%d%d", &L, &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		b[i] = L - a[i];
	}

	for (int i = 1; i <= n; ++i) {
		sa[i] = sa[i - 1] + a[i];
		sb[i] = sb[i - 1] + b[i];
	}

	solve();

	for (int i = 1; i <= n; ++i) a[i] = b[n - i + 1];
	for (int i = 1; i <= n; ++i) b[i] = L - a[i];
	for (int i = 1; i <= n; ++i) {
		sa[i] = sa[i - 1] + a[i];
		sb[i] = sb[i - 1] + b[i];
	}
	solve();

	printf("%lld\n", ans);
	return 0;
}
