#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long n, ans;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
  cin >> n;
  vector<long long> a(n * 2);
  for (auto &x : a) cin >> x;
  for (long long i = 0; i < 2 * n; i++) {
    if (i == 0 || a[i] != a[i - 1]) {
      long long j;
      for (j = i + 1; a[j] != a[i]; j++)
        ;
      while (j != i + 1) {
        swap(a[j], a[j - 1]);
        ans++;
        j--;
      }
    }
  }
  cout << ans << '\n';
}
