#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1;

LL solve(LL L, int N, vector<LL> X) {
    X.push_back(L);
    vector<LL> D(N);
    for (int i = 0; i < N; i++) {
        if (i != N-1) D[i] = X[i+1]-X[i];
        else D[i] = L-X[i];
    }
    vector<LL> pref(N+1);
    pref[0] = 0;
    for (int i = 0; i < N; i++) pref[i+1] = pref[i] + i*D[i];
    LL res = 0;
    for (int i = 0; i < N; i++) { // FIXME
        int a = (N+i-2)/2;
        int b = (N+i)/2;
        LL ris = (N-i)*X[i];
        // dbg(ris);
        if (i == N-1) {
            res = max(ris, res);
            // dbg(ris);
            continue;
        } else if (i == N-2) {
            res = max(ris + D[N-1], res);
            // dbg(ris+ D[N-1]);
            continue;
        }
        // dbg(a);
        // dbg(ris);
        // dbg(a);
        ris += (N+i-2)*(X[a+1]-X[i]);
        ris -= 2 * (pref[a+1] - pref[i]);
        // dbg(ris);

        ris -= (N+i-1) * (L-X[b]);
        ris += 2 * (pref[N] - pref[b]);
        // dbg(b);
        // dbg(ris);
        // cout << ris << "\n";
        res = max(res, ris);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    LL L;
    int N;
    cin >> L >> N;
    vector<LL> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    LL res = solve(L, N, X);
    for (int i = 0; i < N; i++) X[i] = L-X[i];
    reverse(X.begin(), X.end());
    res = max(res, solve(L, N, X));
    cout << res << "\n";
}


Measured memory_bytes: 7908