func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   long long n, m, l, r, a[N], b[N], dp[N];   void prework() {     int k = 1;     for (int i = 2; i <= n; ++i)       if (a[i + 1] - a[i] > a[k + 1] - a[k]) k = i;     r = a[k + 1] - a[k] - 1;     for (int i = 1; i <= n; ++i) b[i] = a[i + k];     int t = b[1];     for (int i = 1; i <= n; ++i) b[i] -= t;   }   int check(long long x) {     dp[1] = 0;     for (int i = 2; i <= n; ++i) {       dp[i] = dp[i - 1];       if (dp[i - 1] >= b[i] - 1) dp[i] = max(dp[i], b[i] + x);       if (dp[i - 1] >= b[i] - x - 1) dp[i] = max(dp[i], b[i]);       if (i > 2 && dp[i - 2] >= b[i] - x - 1) dp[i] = max(dp[i], b[i - 1] + x);     }     if (dp[n] >= m - x - 1) return 1;     dp[2] = max(b[2], x);     for (int i = 3; i <= n; ++i) {       dp[i] = dp[i - 1];       if (dp[i - 1] >= b[i] - 1) dp[i] = max(dp[i], b[i] + x);       if (dp[i - 1] >= b[i] - x - 1) dp[i] = max(dp[i], b[i]);       if (dp[i - 2] >= b[i] - x - 1) dp[i] = max(dp[i], b[i - 1] + x);     }     return dp[n] >= min(m - 1, m + b[2] - x - 1);   }   int main() {     ios::sync_with_stdio(false);     cin >> m >> n;     for (int i = 1; i <= n; ++i) cin >> a[i], a[i + n] = a[i] + m;     if (n == 1) return cout << m - 1 << endl, 0;     sort(a + 1, a + n * 2 - 1);     prework();     while (l < r) {       long long mid = (l + r) >> 1;       if (check(mid))         r = mid;       else         l = mid + 1;     }     cout << l << endl;     return 0;   }   