func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> ev[1000099];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> p(n), pos(n);     for (int(i) = (0); (i) < (int)(n); ++(i)) {       cin >> p[i];       p[i]--;       pos[p[i]] = i;       ev[n - i].push_back(p[i]);       int k = (p[i] - i + n) % n;       if (k != n - i) ev[k].push_back(p[i]);     }     long long sm = 0;     int x = 0, y = 0;     vector<int> state(n);     for (int(i) = (0); (i) < (int)(n); ++(i)) {       if (i < p[i])         x++, state[p[i]] = -1;       else         y++, state[p[i]] = 1;       sm += abs(i - p[i]);     }     long long mi = LLONG_MAX;     int ans = -1;     for (int(i) = (0); (i) < (int)(n); ++(i)) {       if (i > 0) {         for (auto &(num) : (ev[i])) {           int nextPos = (pos[num] + i) % n;           int prePos = (pos[num] + i - 1) % n;           int nextState = nextPos < num ? -1 : 1;           sm += abs(nextPos - num) - abs(prePos - num);           if (state[num] == -1 && nextState == 1) {             sm--;             x--;             y++;             state[num] = 1;           } else if (state[num] == 1 && nextState == -1) {             sm++;             x++;             y--;             state[num] = -1;           } else if (state[num] == nextState) {             if (state[num] == 1)               sm--;             else               sm++;           }         }         sm -= x;         sm += y;       }       if (sm < mi) {         ans = i;         mi = sm;       }     }     cout << mi <<     << ans << endl;   }   