#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T>
ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}

const int N = 2e5 + 10;

ll pref[N];

ll get_pref(int l, int r) {
    if (l > r) return 0;
    if (!l--) return pref[r];
    return pref[r] - pref[l];
}
#ifdef MAX_HOME
const int S = 1000;
#else
const int S = 447;
#endif
vl d;
ll res[(N + N) / S], sum[(N + N) / S];
int n;

ll get(int l, int len) {
    int r = l + len - 1;
    ll ret = 0;
    for (int i = l, k = 1; i <= r; ) {
        int ind = i / S;
        int st = ind * S;
        int fin = min(st + S - 1, n - 1);
        if (l <= st && r >= fin) {
            ret += sum[ind] * (k - 1) + res[ind];
            k += 2LL * (fin - st + 1);
            i = fin + 1;
        } else {
            ret += d[i] * k;
            ++i;
            k += 2;
        }

    }
    return ret;
}


ll solve(vl dd) {
    d = dd;
    n = d.size();
    pref[0] = d[0];
    for (int i = 1; i < n; ++i) pref[i] = pref[i - 1] + d[i];

    for (int i = 0; i < n; ++i) {
        int ind = i / S;
        int st = ind * S;
        int fin = min(st + S - 1, n - 1);
        res[ind] = sum[ind] = 0;
        for (int j = st, k = 1; j <= fin; ++j, k += 2) {
            res[ind] += d[j] * k;
            sum[ind] += d[j];
        }

        i = fin;
    }

    ll ret = get_pref(1, n - 1);
    ll add = 0, sm = 0;
    for (int i = 1; i < n; ++i) {
        if (i * 2 > n - 1) break;
        add += d[i - 1];
        sm += add;
        add += d[i - 1];
        ll a = get_pref(0, i - 1) + sm + get(i + 1, i) + (i * 2 + 1) * get_pref(i * 2 + 1, n - 1);
        ll b = get_pref(i + 1, n - 1) + sm + get(i + 1, i) + (i * 2 - 1) * get_pref(i * 2 + 1, n - 1);
//        ll cur = max(get_pref(0, i - 1), get_pref(i + 1, n - 1)) + sm + get(i + 1, i) + ((i - 1) * 2 + 1)  * get_pref(i * 2 + 1, n - 1);
        ll cur = max(a, b);
        inmax(ret, cur);
    }
    return ret;
}

void smain() {

    int len, n;
    cin >> len >> n;
    vi x(n);
    vl d;
    fori (i, n) {
        cin >> x[i];
        d.push_back(x[i] - x[i - 1]);
        if (i == n - 1) d.push_back(len - x[i]);
    }
    ll ans = solve(d);
    reverse(ALL(d));
    inmax(ans, solve(d));
    cout << ans;
}

Measured memory_bytes: 7408