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 f(ulong[] arr, ulong pos, ulong fb)
	{
		if (arr.length == 0) return 0;
		ulong d_f, d_b;
		if (fb == 1)
		{
			d_f = arr.front + (L - pos);
			d_b = pos - arr.back;

		}
		else
		{
			d_f = arr.front - pos;
			d_b = pos + (L - arr.back);
		}
		return max(f(arr[1..$], arr[0], 0) + d_f, f(arr[0..$-1], arr[$-1], 1) + d_b);
	}

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

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