#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
long long a[MAXN],b[MAXN],c[MAXN];
long long l;
int n;
int main()
{
    scanf("%lld",&l);
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%lld",&a[i]);
    }
    for (int i=1;i<=n;i++) b[i]=b[i-1]+a[i];    
    for (int i=n;i>=1;i--) c[i]=c[i+1]+l-a[i];
    if (n==1) cout << max(a[1],l-a[1]) <<endl;
     else if (n==2) cout << max(a[1],l-a[2])+max(a[2]-a[1],l-(a[2]-a[1])) << endl;
     else {
        long long ans=a[n];
        for (int i=1;i<n;i++)
        if (i<n-i) ans=max(max(ans,b[i]*2+(c[i+1]-c[i*2+2])*2-(l-a[i+1])),b[i]*2+(c[i+1]-c[i*2+1])*2-a[i]);
        else if (i>n-i) ans=max(max(ans,(b[i]-b[i-n+i-1])*2+c[i+1]*2-(a[i])),(b[i]-b[i-n+i])*2+c[i+1]*2-(l-a[i+1]));
        else ans=max(ans,b[i]*2+c[i+1]*2-min(l-a[i+1],a[i]));
        cout << ans << endl;
     }
}