#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, a[MAXN * 2], pos[MAXN][2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n; ++i) {
    scanf("%d", &a[i]);
    if (pos[a[i]][0] == 0) {
      pos[a[i]][0] = i;
    } else {
      pos[a[i]][1] = i;
    }
  }
  int sasha = 1, dima = 1;
  long long cost = 0;
  for (int i = 1; i <= n; ++i) {
    cost += abs(pos[i][0] - sasha);
    cost += abs(pos[i][1] - dima);
    sasha = pos[i][0];
    dima = pos[i][1];
  }
  printf("%lld\n", cost);
  return 0;
}
