#include <bits/stdc++.h>
using namespace std;
template <class T>
void readi(T &x) {
  T input = 0;
  bool negative = false;
  char c = ' ';
  while (c < '-') {
    c = getchar();
  }
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  while (c >= '0') {
    input = input * 10 + (c - '0');
    c = getchar();
  }
  if (negative) {
    input = -input;
  }
  x = input;
}
template <class T>
void printi(T output) {
  if (output == 0) {
    putchar('0');
    return;
  }
  if (output < 0) {
    putchar('-');
    output = -output;
  }
  int aout[20];
  int ilen = 0;
  while (output) {
    aout[ilen] = ((output % 10));
    output /= 10;
    ilen++;
  }
  for (int i = ilen - 1; i >= 0; i--) {
    putchar(aout[i] + '0');
  }
  return;
}
template <class T>
void ckmin(T &a, T b) {
  a = min(a, b);
}
template <class T>
void ckmax(T &a, T b) {
  a = max(a, b);
}
long long randomize(long long mod) {
  return ((1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}
const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-20;
long long normalize(long long x, long long mod = 1000000007) {
  return (((x % mod) + mod) % mod);
}
int N;
int arr[213];
pair<int, int> pos[213];
int ans;
int32_t main() {
  ios_base::sync_with_stdio(0);
  srand(time(0));
  if (fopen("cf995b.in", "r")) {
    freopen("cf995b.in", "r", stdin);
    freopen("cf995b.out", "w", stdout);
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    pos[i] = make_pair(-1, -1);
  }
  for (int i = 0; i < 2 * N; i++) {
    cin >> arr[i];
    arr[i]--;
    if (pos[arr[i]].first == -1) {
      pos[arr[i]].first = i;
    } else {
      pos[arr[i]].second = i;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int cnt = 0;
      if (pos[i].first > pos[j].first) cnt++;
      if (pos[i].second > pos[j].first) cnt++;
      if (pos[i].first > pos[j].second) cnt++;
      if (pos[i].second > pos[j].second) cnt++;
      ans += min(cnt, 4 - cnt);
    }
  }
  cout << ans << '\n';
  return 0;
}
