#include <bits/stdc++.h>
using namespace std;
const int N = 201;
int n, a[N], ans;
int f[N];
bool vis[N];
struct FenwickTree {
  int t[N];
  void update(int p, int v) {
    for (; p < N; p += p & -p) t[p] += v;
  }
  int get(int p) {
    int ans = 0;
    for (; p; p -= p & -p) ans += t[p];
    return ans;
  }
} Ft;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= 2 * n; ++i) {
    cin >> a[i];
    f[a[i]] = i;
    Ft.update(i, 1);
  }
  for (int i = 1; i <= 2 * n; ++i) {
    if (!vis[a[i]]) {
      ans += Ft.get(f[a[i]]) - Ft.get(i) - 1;
      vis[a[i]] = 1;
      Ft.update(f[a[i]], -1);
    }
  }
  cout << ans;
}
