#include<bits/stdc++.h>
using namespace std;

#define In inline
#define Op operator
#define Rg register
#define St static

typedef long long ll;

const int mxN=1<<18;

int main()
{
    St ll a[mxN], b[mxN], c[mxN];
    int n, m;
    scanf("%d%d", &n, &m);
    for(Rg int i=1; i<=m; ++i)
    {
        scanf("%lld", a+i);
        b[i]=b[i-1]+a[i];
        c[i]=c[i-1]+n-a[i];
    }
    a[m+1]=n;
    Rg ll ans=max(n-a[1], a[m]);
    for(Rg int i=1; i<m; ++i)
    {
        Rg int j=min(i-1, m-i), k=min(i, m-i-1), l=min(i, m-i);
        ans=max(ans, max
        (
            max
            (
                2*(b[i-1]-b[i-j-1]+c[i+j]-c[i])+a[i],
                2*(b[i]-b[i-k]+c[i+k+1]-c[i+1])+n-a[i+1]
            )
            , 2*(b[i]-b[i-l]+c[i+l]-c[i])-min
            (
                a[i],
                n-a[i+1]
            )
        )
        );
    }
    printf("%lld\n", ans);
    return 0;
}
