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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

ll solve1(ll L, int N, vll& x) {
    vll _x(N);
    rep(i,N) _x[i] = L - x[N-1-i];

    vll a(N, 0);

    a[0] = x[0];
    for (int c=0; c<N-1; ++c) {
        a[0] += x[(c+1)/2] + _x[c/2];
    }
    int h = N;
    int pos = 0+(h-1)/2, neg = (h-2)/2;
    bool end_in_neg = (h % 2) == 0;


    for (int i=1; i<N-1; ++i) {
        int h = N-i;

        int pos = i+(h-1)/2, neg = (h-2)/2;
        bool end_in_neg = (h % 2) == 0;

        a[i] = a[i-1];
        if (end_in_neg) {
            a[i] -= _x[neg] + x[pos];
            int u = h/2;
            a[i] += 2*(x[pos] - x[i-1]);
        } else {
            a[i] -= _x[neg+1] + x[pos];
            int u = h/2 + 1;
            a[i] += 2*(x[pos] - x[i-1]);
        }
    }

    ll ans = max(L-x[0], L-x[N-1]);
    ans = max(ans, *max_element(ALL(a)));
    return ans;
}

ll solve_s(ll L, int N, vll& x) {
    if (N > 2000) return accumulate(ALL(x), 0LL)/2;

    vector<vector<vector<ll>>> dp(2,
        vector<vector<ll>>(N+1,
            vector<ll>(2, -1)
        )
    );


    int w = N+1;

    vll _x(N);
    rep(i,N) _x[i] = L - x[N-1-i];

    dp[1][1][0] = x[0];
    dp[1][0][1] = _x[0];
    for (int n=2; n<=N; ++n) {
        int f = (n-1)%2, t = 1-f;
        dp[t].assign(N+1, vector<ll>(2, -1));
        rep(a,n) {
            int b = (n-1)-a;
            if (dp[f][a][0] != -1) {
                assert(a>0);
                int a_ = (a+1)%N;
                ll h0 = dp[f][a][0] + (x[a] - x[a-1]);
                dp[t][a_][0] = max(dp[t][a_][0], h0);
                ll h1 = dp[f][a][0] + x[a-1] + _x[b];
                dp[t][a][1] = max(dp[t][a][1], h1);
            }
            if (dp[f][a][1] != -1) {
                assert(b>0);
                int a_ = (a+1)%N;
                int b_ = (b+1)%N;
                ll h1 = dp[f][a][1] + (_x[b] - _x[b-1]);
                dp[t][a][1] = max(dp[t][a][1], h1);
                ll h0 = dp[f][a][1] + _x[b-1] + x[a];
                dp[t][a_][0] = max(dp[t][a_][0], h0);
            }
        }
    }
    ll ans = 0;
    rep(i,N+1) {
        ans = max(ans, dp[N%2][i][0]);
        ans = max(ans, dp[N%2][i][1]);
    }
    return ans;
}

int main() {
    ll L; int N; scanf("%lld%d", &L, &N);
    vll X(N);
    rep(i,N) scanf("%lld", &X[i]);

    ll a = solve1(L,N,X);
    reverse(ALL(X)); rep(i,N) X[i]=L-X[i];
    ll b = solve1(L,N,X);
    cout << max(a,b) << endl;
    return 0;
}


Measured memory_bytes: 4992