#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<int, int> first;
  map<int, int> last;
  int n;
  cin >> n;
  vector<int> v(2 * n);
  vector<pair<int, int>> p;
  for (int i = 0; i < 2 * n; ++i) {
    cin >> v[i];
    if (!first.count(v[i]))
      first[v[i]] = i;
    else {
      last[v[i]] = i;
      if (last[v[i]] - first[v[i]] > 1) p.push_back({first[v[i]], last[v[i]]});
    }
  }
  sort(begin(p), end(p),
       [&](pair<int, int> &a, pair<int, int> &b) { return a.first < b.first; });
  int ans = 0;
  while (!p.empty()) {
    int a, b;
    tie(a, b) = *p.begin();
    while (b != a + 1) {
      swap(v[b], v[b - 1]);
      ++ans;
      --b;
    }
    first.clear();
    last.clear();
    p.clear();
    for (int i = 0; i < 2 * n; ++i) {
      if (!first.count(v[i]))
        first[v[i]] = i;
      else {
        last[v[i]] = i;
        if (last[v[i]] - first[v[i]] > 1)
          p.push_back({first[v[i]], last[v[i]]});
      }
    }
    sort(begin(p), end(p), [&](pair<int, int> &a, pair<int, int> &b) {
      return a.first < b.first;
    });
  }
  cout << ans << endl;
}
