#include <bits/stdc++.h>
using namespace std;
void FAST_IO();
vector<long long int> v[1000000];
int main() {
  clock_t tStart = clock();
  long long int n;
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) {
    long long int temp;
    cin >> temp;
    v[temp].push_back(i);
  }
  int f1 = 0, f2 = 0, f3 = 0, f4 = 0;
  long long int x = 1, y = 1, ans1 = 0, ans2 = 0, ans3 = 0;
  for (int i = 1; i <= n; i++) {
    f1 += abs(x - v[i][0]);
    f2 += abs(y - v[i][1]);
    int temp = abs(x - v[i][0]) + abs(y - v[i][1]);
    int temp2 = abs(x - v[i][1]) + abs(y - v[i][0]);
    if (temp < temp2) {
      ans1 += abs(x - v[i][0]);
      ans2 += abs(y - v[i][1]);
      ans3 += temp;
      x = v[i][0];
      y = v[i][1];
    } else {
      ans2 += abs(x - v[i][0]);
      ans1 += abs(y - v[i][1]);
      ans3 += temp2;
      y = v[i][0];
      x = v[i][1];
    }
  }
  cout << ans3 << '\n';
  return 0;
}
void FAST_IO() {
  ios_base::sync_with_stdio(0);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
