#include <bits/stdc++.h>
using namespace std;
long long a[100000][3];
int main() {
  long long n, i, d1, d2, s = 0, nr, D, S, dif1, dif2, p1, p2, poz1, poz2;
  scanf("%I64d", &n);
  for (i = 1; i <= 2 * n; i++) {
    scanf("%I64d", &nr);
    a[nr][++a[nr][0]] = i;
    if (a[nr][0] == 2)
      if (a[nr][1] > a[nr][2]) swap(a[nr][1], a[nr][2]);
  }
  D = S = 1;
  for (i = 1; i <= n; i++) {
    s = s + (abs)(S - a[i][1]);
    S = a[i][1];
    s = s + (abs)(D - a[i][2]);
    D = a[i][2];
  }
  printf("%I64d", s);
  return 0;
}
