#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll L, N;
ll X[210010];
ll dp[2010][2010][2]; //  l, r


ll dfs(ll l, ll r, ll pos){
    if(dp[l][r][pos] >= 0) return dp[l][r][pos];
    ll res = 0;
    if((l + 1) % N == r) {
        res = 0;
    }
    else{
        // to l 
        {
            if(pos == 0){
                res = max(res, dfs(l + 1, r, 0) + (X[l+1] - X[l]));
            }
            else if(pos == 1){
                res = max(res, dfs(l + 1, r, 0) + (X[l+1] + (L - X[r])));
            }
        }
        // to r
        {
            if(pos == 1){
                res = max(res, dfs(l, (r - 1 + N) % N, 1) + (X[r] - X[(r - 1 + N) % N]));
            }
            else if(pos == 0){
                res = max(res, dfs(l, (r - 1 + N) % N, 1) + (X[l] + (L - X[(r - 1 + N) % N])));
            }
        }
    }
    return dp[l][r][pos] = res;
}

ll solve2(){
    for(int i = 0; i < N; i++) X[N-i] = X[N-1-i];
    N++;
    X[0] = 0;

    if(N == 2){
        return  max(X[1], L-X[1]);
    }
    else{
        memset(dp, -1, sizeof(dp));
        return dfs(0, 0, 0);
    }
}

ll sums[200010];
ll solve1(){
    ll ans = 0;
    for(int ite = 0; ite < 2; ite++){
        sums[0] = 0;
        for(int i = 0; i < N; i++)
            sums[i + 1] = sums[i] + X[i];
        // 最初にどこまで左にいくか
        for(ll i = 0; i < N; i++){
            ll s = X[i];
            // iから右、左と加算していく
            if(i != N - 1) {
                s += X[i];
                // 偶数個残る場合
                if((N - 1 - i) % 2 == 0){
                    // (N - 1 + (i + 1)) / 2
                    int l1 = i + 1;
                    int r1 = (N - 1 + (i + 1)) / 2;
                    int l2 = r1 + 1;
                    int r2 = N - 1;
                    if(i == 1 && ite == 1){
                        // cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
                        // cout << s << endl;
                        // cout << max(0LL, sums[r1+1] - sums[l1]) << endl;
                        // cout << max(0LL, sums[r2+1] - sums[l2]) << endl;
                        // cout <<  L * (N - 1 - i) / 2 << endl;
                    }
                    s += 2 * (max(0LL, sums[r1+1] - sums[l1]) - max(0LL, sums[r2+1] - sums[l2]) + L * (N - 1 - i) / 2);
                    s -= X[r1];
                }
                // 奇数個残る場合
                else{
                    // (N - 1 + (i + 1)) / 2
                    int l1 = i + 1;
                    int l2 = (N - 1 + (i + 1)) / 2;
                    int r1 = l2 - 1;
                    int r2 = N - 1;
                    // if(i == 1 && ite == 0){
                    //     cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
                    // }
                    s += 2 * (max(0LL, sums[r1+1] - sums[l1]) - max(0LL, sums[r2+1] - sums[l2]) + L * ((N - 1 - i) / 2 + 1));
                    s -= (L-X[l2]);
                }
            }
            // cout << ite << "," << s << endl;
            ans = max(ans, s);
        }
        // 反転してもう一度行う(座標をL-X[i]する)
        for(int i = 0; i < N; i++){
            X[i] = L - X[i];
        }
        reverse(X, X + N);
        // for(int i = 0; i < N; i++){
        //     cout << X[i] << endl;
        // }
    }
    return ans;
}

int main(){

    cin >> L >> N;
    for(ll i = 0; i < N; i++){
        cin >> X[i];
    }
    cout << solve1() << endl;
    // cout << solve2() << endl;
 
    return 0;
}


Measured memory_bytes: 4608