#include <bits/stdc++.h>
using namespace std;
long long vis[100005];
long long vis1[100005];
int main() {
  long long n, i, j;
  cin >> n;
  for (i = 1; i <= n * 2; i++) {
    cin >> j;
    if (vis[j])
      vis1[j] = i;
    else
      vis[j] = i;
  }
  long long ans = abs(1 - vis[1]);
  for (i = 2; i <= n; i++) ans += abs(vis[i] - vis[i - 1]);
  ans += abs(1 - vis1[1]);
  for (i = 2; i <= n; i++) ans += abs(vis1[i] - vis1[i - 1]);
  cout << ans;
}
