import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long l = read.to!long;
	long n = read.to!long;
	
	long[] xs;
	foreach(i; 0 .. n) xs ~= read.to!long;
	
	long[][] p; // 今原点より右にいて、右側i本と左側j本を焼いたときの最大値がp[k][i] // 0 < i; 0 <= j; i + j <= n
	long[][] q; // 今原点より左にいて、右側i本と左側j本を焼いたときの最大値がq[k][j] // 0 <= i; 0 < j; i + j <= n
	foreach(i; 0 .. n + 1){
		long[] tmp1, tmp2;
		foreach(j; 0 .. n + 1){
			tmp1 ~= -1, tmp2 ~= -1;
		}
		p ~= tmp1, q ~= tmp2;
	}
	
	p[1][0] = xs[0];
	q[0][1] = l - xs[n - 1];
	
	// p[i][0] は p[i - 1][0] + (xs[i] - xs[i - 1])
	// q[0][j] は q[i - 1][j] + (xs[n - j] - xs[n - j + 1])
	
	foreach(i; 1 .. n + 1){
		if(i > 1) p[i][0] = p[i - 1][0] + (xs[i - 1] - xs[i - 2]);
		q[i][1] = p[i][0] + (xs[i - 1] + l - xs[n - 1]);
	}
	foreach(j; 1 .. n + 1){
		if(j > 1) q[0][j] = q[0][j - 1] + (xs[n - j + 1] - xs[n - j]);
		p[1][j] = q[0][j] + (xs[0] + l - xs[n - j]);
	}
	

	// p[i][j] は p[i - 1][j] + (xs[i] - xs[i - 1]) と q[i - 1][j] + (xs[i] + l - xs[n - j]) の大きい方
	// q[i][j] は q[i][j - 1] + (xs[i] + l - xs[n - j]) と q[i][j - 1] + (xs[n - j] - xs[n - j + 1]) の大きい方
	
	foreach(i; 1 .. n + 1){
		foreach(j; 1 .. n + 1){
			if(i > 1) p[i][j] = max(p[i - 1][j] + (xs[i - 1] - xs[i - 2]), q[i - 1][j] + (xs[i - 1] + l - xs[n - j]));
			if(j > 1) q[i][j] = max(p[i][j - 1] + (xs[i - 1] + l - xs[n - j]), q[i][j - 1] + (xs[n - j + 1] - xs[n - j]));
		}
	}
	
	debug writeln("p:");
	debug foreach(pl; p) pl.writeln;
	debug writeln("q:");
	debug foreach(ql; q) ql.writeln;
	
	long ans = 0;
	foreach(i; 0 .. n + 1){
		if(p[i][n - i] > ans) ans = p[i][n - i];
		if(q[i][n - i] > ans) ans = q[i][n - i];
	}
	
	ans.writeln;
}
