func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const int maxn = 1000100;   int cnt_neg = 0, cnt_pos = 0;   int arr[maxn << 1];   int main() {     int n;     scanf( %d , &n);     for (int e = 1; e <= n; e++) scanf( %d , arr + e), arr[e + n] = arr[e];     int hi = 2 * n, lo = n + 1, nowlo = n;     long long sum = 0;     set<pair<int, int> > go;     unordered_set<int> removido;     for (int cur = hi; cur >= lo; cur--) {       if (arr[cur] <= nowlo)         cnt_pos++;       else         cnt_neg++, go.insert(make_pair(arr[cur] - nowlo, cur));       sum += abs(arr[cur] - nowlo);       nowlo--;     }     long long ans = sum, shift = 0, state = 0;     for (; lo > 1;) {       if (arr[hi] <= n)         cnt_pos--;       else         cnt_neg--;       sum -= abs(arr[hi] - n);       removido.insert(hi);       shift++;       sum += -cnt_neg + cnt_pos;       sum += abs(arr[lo - 1] - 1);       if (sum < ans) ans = sum, state = shift;       if (arr[lo - 1] > 1)         cnt_neg++, go.insert(make_pair(shift + arr[lo - 1] - 1, lo - 1));       else         cnt_pos++;       while (!go.empty()) {         int shi, val;         tie(shi, val) = *go.begin();         int removal = removido.count(val);         if (!(removal || shi == shift)) break;         if (!removal)           cnt_neg--, cnt_pos++;         else           removido.erase(go.begin()->second);         go.erase(go.begin());       }       lo--;       hi--;     }     printf( %lld %lld n , ans, state);     return 0;   }   