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