#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<pair<int, bool>> v(2 * n);
  for (int i = 0; i < 2 * n; i++) cin >> v[i].first, v[i].second = true;
  long long ans = 0, cc = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (!v[i].second) continue;
    cc = 0;
    v[i].second = false;
    for (int j = i + 1; j < 2 * n; j++) {
      if (v[j].second && v[i].first != v[j].first) {
        cc++;
      } else if (v[i].first == v[j].first) {
        v[j].second = false;
        break;
      }
    }
    ans += cc;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int chill = 1;
  while (chill--) {
    solve();
  }
}
