l,n = gets.split.map(&:to_i)
x = n.times.map{gets.to_i}
a = Array.new(n+1){|i|i == 0 ? 0 : x[i-1]}
b = Array.new(n+1){|i|i == 0 ? 0 : l-x[-i]}
n.times do |i|
    a[i+1] += a[i]
    b[i+1] += b[i]
end
ans = 0
for i in 0..n-2
    diff = x[i+(n-i-1)/2+1]-x[i+(n-i-1)/2]
    ret = (a[i+(n-i-1)/2]-a[i]+b[(n-i)/2-1])*2+((i+n)%2 == 0 ? x[i+(n-i-1)/2] : l-x[i+(n-i-1)/2+1])+(diff > l-diff ? diff : l-diff)
    ans = ret if ans < ret
end
n.times do |i|
    x[i] = l-x[i]
end
x.reverse!
a,b = b,a
for i in 0..n-2
    diff = x[i+(n-i-1)/2+1]-x[i+(n-i-1)/2]
    ret = (a[i+(n-i-1)/2]-a[i]+b[(n-i)/2-1])*2+((i+n)%2 == 0 ? x[i+(n-i-1)/2] : l-x[i+(n-i-1)/2+1])+(diff > l-diff ? diff : l-diff)
    ans = ret if ans < ret
end
ans = [l-x[0],x[0]].max if n == 1
puts ans