#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[2 * n + 1];
  vector<vector<long long int> > b(n + 1, vector<long long int>(2, 0));
  for (long long int i = 1; i <= 2 * n; i++) {
    cin >> a[i];
    if (b[a[i]][0] == 0) {
      b[a[i]][0] = i;
    } else {
      b[a[i]][1] = i;
    }
  }
  long long int d = 0;
  for (long long int i = 0; i < 2; i++) {
    long long int c = 1;
    for (long long int j = 1; j <= n; j++) {
      d += abs(b[j][i] - c);
      c = b[j][i];
    }
  }
  cout << d;
}
