#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int l,n;
  cin>>l>>n;
  vector<int> x(n+2,0);
  for(int i=1;i<=n;i++)cin>>x[i];
  x[n+1]=l;
  vector<int> rui(n+2,0);
  for(int i=1;i<=n;i++){
    rui[i]=rui[i-1]+x[i];
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int tmp;
    int nn=n-i;
    tmp=max(nn*l+2*(rui[i+nn/2]-rui[i-1])-x[i+(nn+1)/2]-2*(rui[n]-rui[i+(nn+1)/2]),
        i*l+2*rui[(i-1)/2]+x[(i+1)/2]-2*(rui[i]-rui[i-(i+1)/2]));
    ans=max(tmp,ans);

  }
  cout<<ans<<endl;
}
