l,n=map(int,input().split())
tree=[]
for i in range(n):
  k=int(input())
  tree.append(k)

reverse_tree=[l-i for i in tree]
reverse_tree.reverse()

position=0
ans=0
flag=True

def loop(i,j,tf):
    global flag
    global ans
    global position
    position_A=tree[i]
    position_B=l-reverse_tree[j]
    ans_A=0
    ans_B=0
    if (i!=0 or j!=0) and tf:
        ans_A+= tree[i]-tree[i-1]
        ans_B+= reverse_tree[j]+tree[i-1]
    elif i!=0 or j!=0:
        ans_A+= reverse_tree[j-1]+tree[i]
        ans_B+= reverse_tree[j-1]+reverse_tree[j]
    if (tree[i+1]-position_A >= reverse_tree[j]+position_A):
        ans_A+= tree[i+1]-position_A
    else:
        ans_A+= reverse_tree[i]+position_A
    if (l-position_B+tree[i] >= position_B-l+reverse_tree[j+1]):
        ans_B+= l-position_B+tree[i]
    else:
        ans_B+= position_B-l+reverse_tree[j+1]
    if ans_A == ans_B:
        A_1  = ans_A
        B_1  = ans_B
        ans_A = A_1 + loop(i+1,j,True)
        ans_B = B_1 + loop(i,j+1,False)
    if i==0 and j==0 and flag==True:
        if ans_A > ans_B:
            ans+= tree[0]-position
            position=tree.pop(0)
            reverse_tree.pop(-1)
        elif ans_B > ans_A:
            ans+= reverse_tree[0]+position
            position=l-reverse_tree.pop(0)
            tree.pop(-1)
            flag=False
    elif i==0 and j==0 and flag==False:
        if ans_A > ans_B:
            ans+= l-position+tree[0]
            position=tree.pop(0)
            reverse_tree.pop(-1)
            flag=True
        elif ans_B > ans_A:
            ans+= position-l+reverse_tree[0]
            position=l-reverse_tree.pop(0)
            tree.pop(-1)
    return max(ans_A,ans_B)

while len(tree)>0:
    if flag:
        if (tree[0]-position > reverse_tree[0]+position):
            ans+= tree[0]-position
            position=tree.pop(0)
            reverse_tree.pop(-1)
        elif (tree[0]-position == reverse_tree[0]+position):
            loop(0,0,True)
        else:
            ans+= reverse_tree[0]+position
            position=l-reverse_tree.pop(0)
            tree.pop(-1)
            flag=False
    else:
        if (l-position+tree[0] > position-l+reverse_tree[0]):
            ans+= l-position+tree[0]
            position=tree.pop(0)
            reverse_tree.pop(-1)
            flag=True
        elif (l-position+tree[0] == position-l+reverse_tree[0]):
            loop(0,0,False)
        else:
            ans+= position-l+reverse_tree[0]
            position=l-reverse_tree.pop(0)
            tree.pop(-1)
    print(position)

print(ans)


### FIXED CODE ###

import sys
from collections import deque
l,n=map(int,input().split())
c=n
tree1=[int(i) for i in sys.stdin]
reversed_tree1=[l-i for i in reversed(tree1)]
tree=deque(tree1)
reversed_tree=deque(reversed_tree1)
if n%2 == 0:
  ans= sum(tree1)*2 + l*(n-1) +tree1[n//2] - sum(tree1[n//2:])*4
  ans2= sum(reversed_tree1)*2 + l*(n-1) +reversed_tree1[n//2] - sum(reversed_tree1[n//2:])*4
  n-=1
  c-=1
  ans3= ans-tree.popleft()*2-l+tree[n//2]*2
  ans= max(ans,ans3)
  ans4= ans2-reversed_tree.popleft()*2-l+(reversed_tree[n//2])*2
  ans2= max(ans2,ans4)
else:
  ans= sum(tree1)*2 + l*(n-1) - tree1[n//2] - sum(tree1[((n//2)+1):])*4
  ans3=ans
  ans2= sum(reversed_tree1)*2 + l*(n-1) - reversed_tree1[n//2] - sum(reversed_tree1[((n//2)+1):])*4
  ans4=ans2
for i in range(n//2):
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[(n-1)//2]+tree[(n+1)//2]
  ans= max(ans_stack,ans)
  ans3=ans_stack
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[n//2]*2
  ans=max(ans_stack,ans)
  ans3=ans_stack
n=c
for i in range(n//2):
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[(n-1)//2]+reversed_tree[(n+1)//2]
  ans2=max(ans_stack,ans2)
  ans4=ans_stack
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[n//2]*2
  ans2=max(ans2,ans_stack)
  ans4=ans_stack
print(max(ans,ans2))