func_code_string: #include <bits/stdc++.h>   using namespace std;   long long a[1000007], b[1000007], i, n, x, s, f, t;   int main() {     cin >> n;     for (i = 1; i <= 2 * n; i++) {       cin >> x;       if (a[x] == 0)         a[x] = i;       else if (a[x] != 0)         b[x] = i;     }     s = a[1] - 1;     for (x = 2; x <= n; x++) {       t = a[x] - a[x - 1];       if (t < 0) t = -t;       s = s + t;     }     s = s + b[1] - 1;     for (x = 2; x <= n; x++) {       t = b[x] - b[x - 1];       if (t < 0) t = -t;       s = s + t;     }     cout << s;     return 0;   }   