#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int was[100100];
int t[100100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  vector<int> ans;
  int cnt = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (!was[a[i]]) {
      t[a[i]] = i;
      ans.push_back(a[i]);
      was[a[i]] = true;
    } else {
      was[a[i]] = true;
      cnt += i - t[a[i]] - 1;
      ans.insert(ans.begin() + t[a[i]] + 1, a[i]);
      for (int j = 0; j < ans.size(); j++) {
        t[ans[j]] = j;
      }
    }
  }
  cout << cnt;
  return 0;
}
