#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); i++)

signed main() {
	int l, n;
	cin >> l >> n;
	vector<int> d(n);
	rep(i, n) {
		cin >> d[i];
	}
	vector<int> sum(n), rsum(n);
	int now = 0;
	int rnow = 0;
	rep(i, n) {
		sum[i] = now;
		rsum[n - 1 - i] = rnow;
		now += d[i];
		rnow += l - d[n - 1 - i];
	}
	int ans = 0;
	rep(i, n / 2) {
		now = (sum[i] + (rsum[i] - rsum[i * 2])) * 2;
		ans = max(ans, now + l - d[i]);
		now = (sum[i] + (rsum[i] - rsum[i * 2 + 1])) * 2;
		ans = max(ans, now + d[i]);
	}
	rep(i, n / 2) {
		now = (rsum[n - 1 - i] + (sum[n - 1 - i] - sum[n - 1 - (i * 2)])) * 2;
		ans = max(ans, now + d[n - 1 - i]);
		now = (rsum[n - 1 - i] + (sum[n - 1 - i] - sum[n - 1 - (i * 2 + 1)])) * 2;
		ans = max(ans, now + l - d[n - 1 - i]);
	}
	if(n % 2 == 1) {
		now = (sum[n / 2] + rsum[n / 2]) * 2;
		ans = max(ans, now + max(d[n / 2], l - d[n / 2]));
	}
	cout << ans << endl;
}