import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto L = to!ulong(tokens[0]);
	auto N = to!ulong(tokens[1]);

	ulong[] X;
	foreach (i; 0..N)
	{
		X ~= to!ulong(my_readln());
	}
	
	ulong[ulong] memo;
	ulong f(ulong[] arr, ulong begin, ulong end, ulong pos, ulong fb)
	{
		if (end == begin) return 0;
		auto key = fb * 1000000000000 + begin * 1000000 + end;
		auto m   = memo.get(key, ulong.max);
		if (m != ulong.max) return m;

		ulong d_f, d_b;
		if (fb == 1)
		{
			d_f = arr[begin] + (L - pos);
			d_b = pos - arr[end-1];
		}
		else
		{
			d_f = arr[begin] - pos;
			d_b = pos + (L - arr[end-1]);
		}
		ulong r = max(f(arr, begin + 1, end, arr[begin], 0) + d_f, f(arr, begin, end - 1, arr[end-1], 1) + d_b);
		memo[key] = r;
		return r;
	}

	auto ans = max(f(X, 1, X.length, X[0], 0) + X[0], f(X, 0, X.length - 1, X[$-1], 1) + L - X[$-1]);

	writeln(ans);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}