#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int L, n, x[MAXN];
LL ans, l[MAXN], r[MAXN];

void solve()
{
    l[0]=r[n+1]=0;
    for(rint i=1; i<=n; ++i) l[i]=l[i-1]+x[i];
    for(rint i=n; i>=1; --i) r[i]=r[i+1]+L-x[i];
    for(rint i=0; i<n; ++i)
    {
        if((n-i)&1)
        {
            int pos=i+1+(n-i)/2;
            ans=max(ans, l[pos-1]+l[pos]+r[pos+1]*2-l[i]*2);
           //printf("%d %d %lld!!!\n", i, pos, ans);
        }
        else
        {
            int pos=i+1+(n-i)/2;
            ans=max(ans, l[pos-1]*2+r[pos]+r[pos+1]-l[i]*2);
            //printf("%d %d %lld!!!\n", i, pos, ans);
        }
    }
}

int main()
{
    scanf("%d%d", &L, &n);
    for(rint i=1; i<=n; ++i) scanf("%d", &x[i]);
    solve();
    for(rint i=1; i<=n; ++i) x[i]=L-x[i];
    reverse(x+1, x+n+1);
    solve();
    printf("%lld\n", ans);
    return 0;
}