#include <bits/stdc++.h>
using namespace std;
long long int ans, s, n, a[100005], b[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) {
    cin >> s;
    if (!a[s])
      a[s] = i;
    else
      b[s] = i;
  }
  long long int p = 1, q = 1;
  for (int i = 1; i <= n; i++) {
    ans += abs(p - a[i]);
    p = a[i];
    ans += abs(q - b[i]);
    q = b[i];
  }
  cout << ans << "\n";
}
