#include <bits/stdc++.h>
using namespace std;
int main(){
  long long l; int n; cin >> l >> n;
  vector<long long> p(n + 1), a(n);
  for(int i = 0; i < n; i++){
    long long x; cin >> x; a[i] = x;
  }
  long long ans = 0;
  auto doTurns = [&](){
  	sort(a.begin(), a.end());
	p[0] = 0;
    for(int i = 0; i < n; i++) p[i + 1] = p[i] + a[i];
    for(int i = 0; i < n; i++){
      int can = min(i, n - 1 - i); // how many turns are possible
      long long now = a[i];
      now += 2 * (p[i] - p[i - can]);
      if(i + can + 1 < n) can++;
      now += 2 * (l * can - p[i + can + 1] + p[i + 1]);
      ans = max(ans, now);
    }
  };
  doTurns();
  for(int i = 0; i < n; i++) a[i] = l - a[i];
  doTurns();
  cout << ans << endl;
  return 0;
}
    
