#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
map<long long, string> M;
int a[3][maxn];
int main() {
  int x, y, z, i, j, n, m;
  memset(a, -1, sizeof(a));
  long long k = 0;
  scanf("%d", &n);
  for (i = 1; i <= n * 2; i++) {
    scanf("%d", &m);
    if (a[0][m] == -1)
      a[0][m] = i;
    else
      a[1][m] = i;
  }
  x = y = 1;
  for (i = 1; i <= n; i++) {
    m = min(abs(a[0][i] - x) + abs(a[1][i] - y),
            abs(a[0][i] - y) + abs(a[1][i] - x));
    x = a[0][i];
    y = a[1][i];
    k += m;
  }
  printf("%I64d\n", k);
  return 0;
}
