#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = (int)2e5 + 5;

int nl, n;
int x[N], y[N];
LL sx[N], sy[N], ans;

void Solve(int *x, int *y) {
  for (int i = 1; i <= n; ++i) {
    sx[i] = sx[i - 1] + x[i] * 2;
  }
  for (int i = n; i >= 1; --i) {
    sy[i] = sy[i + 1] + y[i] * 2;
  }
  for (int i = 1; i <= n; ++i) {
    int lim = i + (n - i) / 2;
    if ((n - i) & 1) {
      ans = max(ans, sx[lim] - sx[i - 1] + sy[lim + 1] - y[lim + 1]);
    } else {
      ans = max(ans, sx[lim] - sx[i - 1] + sy[lim + 1] - x[lim]);
    }
  }
}

int main() {
  scanf("%d%d", &nl, &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x[i]);
    y[i] = nl - x[i];
  }
  Solve(x, y);
  reverse(x + 1, x + 1 + n);
  reverse(y + 1, y + 1 + n);
  Solve(y, x);
  printf("%lld\n", ans);
  return 0;
}
