#include <bits/stdc++.h>
using namespace std;
void SieveOfErat() {
  bool prime[1000001];
  memset(prime, true, sizeof(prime));
  for (long long vec = 2; vec * vec <= 1000000; vec++) {
    if (prime[vec] == true) {
      for (long long dd = vec * 2; dd <= 1000000; dd += vec) prime[dd] = false;
    }
  }
}
long long gcd(long long aa, long long id2) {
  if (aa == 0) {
    return id2;
  } else
    return gcd(aa % id2, id2);
}
struct vect {
  struct vect *foll;
  long long calc;
  struct vect *succ;
};
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a;
  vector<long long> find(n + 1);
  for (long long i = 0; i < 2 * n; i++) {
    long long u;
    cin >> u;
    a.push_back(u);
    find[u] = i;
  }
  long long ans = 0;
  for (long long i = 0; i < 2 * n; i += 2) {
    long long j = find[a[i]];
    while (j != (i + 1)) {
      if (find[a[j - 1]] == j - 1) {
        find[a[j - 1]] += 1;
      }
      swap(a[j], a[j - 1]);
      ans++;
      j--;
    }
  }
  cout << ans << endl;
}
