#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, k, l;
  scanf("%d %d", &m, &n);
  vector<int> positions, distances, cc, cl;
  vector<pair<int, int> > moves;
  for (int i = 0; i < n; i++) {
    scanf("%d", &k);
    positions.push_back(k);
  }
  positions.push_back(m + positions[0]);
  for (int i = 0; i < n; i++) {
    distances.push_back(positions[i + 1] - positions[i] - 1);
  }
  l = 0;
  k = 0;
  for (int i = 0; i < n; i++) {
    if (l < distances[i]) l = distances[i], k = i;
  }
  for (int i = 0; i < n; i++) {
    cc.push_back(distances[(i + k) % n]);
    cl.push_back(distances[(n + k - 1 - i) % n]);
  }
  int i, d1, d2, x = 0, y = m - 1, p = 0;
  while (x != y) {
    k = (x + y) / 2;
    if (k >= l)
      y = (x + y) / 2;
    else {
      i = 0, d1 = k, p = 0;
      while (i < n - 1) {
        if (p + cc[i] <= d1)
          p += (cc[i] + 1), d1 = p + k, i++;
        else if (i < n - 2 and p + cc[i] + cc[i + 1] + 1 - k <= d1)
          d1 = p + cc[i] + 1 + k, p += (cc[i] + cc[i + 1] + 2), i += 2;
        else if (p + cc[i] - k <= d1)
          d1 = p + cc[i] + 1, p += (cc[i] + 1), i++;
        else
          break;
      }
      i = 1, d2 = k, p = cl[0] + 1;
      while (i < n - 1) {
        if (p + cl[i] <= d2)
          p += (cl[i] + 1), d2 = p + k, i++;
        else if (i < n - 2 and p + cl[i] + cl[i + 1] + 1 - k <= d2)
          d2 = p + cl[i] + 1 + k, p += (cl[i] + cl[i + 1] + 2), i += 2;
        else if (p + cl[i] - k <= d2)
          d2 = p + cl[i] + 1, p += (cl[i] + 1), i++;
        else
          break;
      }
      if (d1 < m - 1 and d2 < m - 1 - max(0, k - cl[0] - 1))
        x = (x + y + 1) / 2;
      else
        y = (x + y) / 2;
    }
  }
  cout << x << endl;
  return 0;
}
