#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


pair<LL,LL> search(vector<vector<pair<LL,LL>>>& memo, LL i, LL j, vector<LL>& x, LL l){
    if(i+1 >= j) return pair<LL,LL>(0, 0);
    if(memo[i][j].first >= 0) return memo[i][j];
    pair<LL,LL> res1 = search(memo, i+1, j, x, l);
    pair<LL,LL> res2 = search(memo, i, j-1, x, l);
    pair<LL,LL> ans(0, 0);
    ans.first = res1.first + x[i+1] - x[i];
    ans.first = max<LL>(ans.first, res2.second + (l - x[j-1]) + x[i]);
    ans.second = res2.second + (l - x[j-1]) - (l - x[j]);
    ans.second = max<LL>(ans.second, res1.first + x[i+1] + (l - x[j]));
    memo[i][j] = ans;
    return ans;
}

LL solve1(LL l, LL n, vector<LL>& x){
    vector<vector<pair<LL,LL>>> memo(n+2, vector<pair<LL,LL>>(n+2, pair<LL,LL>(-1,-1)));
    search(memo, 0, n+1, x, l);
    return max<LL>(memo[0][n+1].first, memo[0][n+1].second);
}


LL leftPart(LL b, LL e, vector<LL>& left1, vector<LL>& left2){
    LL score = (left2[e] - left2[b]) * 2;
    score -= (left1[e] - left1[b]) * (b * 2 + 1);
    return score;
}


LL rightPart(LL b, LL e, vector<LL>& right1, vector<LL>& right2){
    LL score = (right2[b] - right2[e]) * 2;
    score -= (right1[b] - right1[e]) * (((right1.size() - 1) - e) * 2 + 2);
    assert(score >= 0);
    return score;
}


LL kougo(LL total, LL b, LL e, vector<LL>& left1, vector<LL>& left2, vector<LL>& right1, vector<LL>& right2){
    if(e - b < 1) return 0;
    LL last = (e + b) / 2;
    LL score = total * (e - b - 1);
    score -= leftPart(b, last, left1, left2);
    score -= rightPart(last, e, right1, right2);
    return score;
}


LL solve2(LL l, LL n, vector<LL>& x){
    vector<LL> left1(x.size());
    vector<LL> left2(x.size());
    vector<LL> right1(x.size());
    vector<LL> right2(x.size());
    for(LL i = 1; i < n+2; ++i){
        left1[i] = left1[i-1] + (x[i] - x[i-1]);
        left2[i] = left2[i-1] + (x[i] - x[i-1]) * i;
    }
    for(LL i = n; i >= 0; --i){
        right1[i] = right1[i+1] + (x[i+1] - x[i]);
        right2[i] = right2[i+1] + (x[i+1] - x[i]) * (n+1 - i);
    }

    LL ans = 0;
    for(LL i = 0; i < n+1; ++i){
        LL cand = x[i];
        cand += kougo(l, i, n+1, left1, left2, right1, right2);
        ans = max<LL>(ans, cand);
    }
    return ans;
}


int main(){
    LL l, n;
    cin >> l >> n;
    vector<LL> x(n+2);
    for(LL i = 0; i < n; ++i){
        cin >> x[i+1];
    }
    x[n+1] = l;
    LL ans = 0;
    if(false){ //n <= 2000){
        ans = solve1(l, n, x);
    }else{
        vector<LL> x2(n+2);
        for(LL i = 0; i < n+2; ++i){
            x2[i] = l - x[n+1-i];
        }
        ans = solve2(l, n, x);
        ans = max<LL>(ans, solve2(l, n, x2));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9616