#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
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 != -1; --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;
}