func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j;     cin >> n;     vector<int> ct[n + 1];     for (i = 0; i < 2 * n; i++) {       int x;       cin >> x;       ct[x].push_back(i);     }     int p1 = 0, p2 = 0;     long long ans = 0;     for (i = 1; i <= n; i++) {       ans += min(abs(ct[i][0] - p1) + abs(ct[i][1] - p2),                  abs(ct[i][0] - p2) + abs(ct[i][1] - p1));       p1 = ct[i][0];       p2 = ct[i][1];     }     cout << ans << endl;   }   