#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || '9' < c; c = getchar())
    if (c == '-') f = -1;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline void write(long long x) {
  static int buf[20], len;
  len = 0;
  if (x < 0) x = -x, putchar('-');
  for (; x; x /= 10) buf[len++] = x % 10;
  if (!len)
    putchar('0');
  else
    while (len) putchar(buf[--len] + '0');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
inline void writesp(long long x) {
  write(x);
  putchar(' ');
}
int f[100010][2];
int a[100010], b[100010];
int n, L;
int check(int mid) {
  int f0 = 0, f1 = 0;
  memset(f, 0x3f, sizeof(f));
  f[0][0] = f0;
  f[0][1] = f1;
  for (int i = 0; i < n; i++) {
    if (f[i][0] <= 0)
      f[i][1] = -mid;
    else if (f[i][0] < mid)
      f[i][1] = std::min(f[i][1], -1);
    else
      return 0;
    f[i + 1][0] = a[i + 1] - a[i] + f[i][1];
    if (f[i][0] > 0 && a[i + 1] - mid < a[i] - f[i][0])
      f[i + 1][1] = a[i + 1] - a[i] - mid;
  }
  if (f[n][0] <= 0)
    f[n][1] = -mid;
  else if (f[n][0] < mid)
    f[n][1] = std::min(f[n][1], -1);
  else
    return 0;
  if (f[n][0] <= f0 && f[n][1] <= f1) return 1;
  f0 = f[n][0];
  f1 = f[n][1];
  memset(f, 0x3f, sizeof(f));
  f[0][0] = f0;
  f[0][1] = f1;
  for (int i = 0; i < n; i++) {
    if (f[i][0] <= 0)
      f[i][1] = -mid;
    else if (f[i][0] < mid)
      f[i][1] = std::min(f[i][1], -1);
    else
      return 0;
    f[i + 1][0] = a[i + 1] - a[i] + f[i][1];
    if (f[i][0] > 0 && a[i + 1] - mid < a[i] - f[i][0])
      f[i + 1][1] = a[i + 1] - a[i] - mid;
  }
  if (f[n][0] <= 0)
    f[n][1] = -mid;
  else if (f[n][0] < mid)
    f[n][1] = std::min(f[n][1], -1);
  else
    return 0;
  if (f[n][0] <= f0 && f[n][1] <= f1) return 1;
  return 0;
}
int main() {
  L = read();
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  int mxd = a[1] + L - a[n], mxid = 1;
  for (int i = 2; i <= n; i++)
    if (a[i] - a[i - 1] > mxd) mxd = a[i] - a[i - 1], mxid = i;
  for (int i = 1; i <= n; i++)
    if (i + mxid - 1 <= n)
      b[i] = a[i + mxid - 1];
    else
      b[i] = a[i + mxid - n - 1] + L;
  for (int i = 1; i <= n; i++) a[i] = b[i];
  a[0] = a[n] - L;
  int l = 1, r = mxd;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (!check(mid))
      l = mid + 1;
    else
      r = mid;
  }
  writeln(l - 1);
  return 0;
}
