#include <bits/stdc++.h>
using namespace std;
const static int MOD = 1000000000 + 7;
const static long long int INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
const static int MAX = 200;
long long int d[MAX + 1][MAX + 1];
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int> > V(n);
  for (size_t i = 0; i < 2 * n; ++i) {
    int a;
    cin >> a;
    V[a - 1].push_back(i);
  }
  int cur_pos_Sasha = 0, cur_pos_Dima = 0;
  long long int ans = 0;
  for (size_t i = 0; i < n; ++i) {
    ans += abs(cur_pos_Sasha - V[i][0]);
    cur_pos_Sasha = V[i][0];
    ans += abs(cur_pos_Dima - V[i][1]);
    cur_pos_Dima = V[i][1];
  }
  cout << ans << endl;
  return 0;
}
