#include <bits/stdc++.h>
using namespace std;
const double g = 9.80665;
const int mod = 998244353;
int a[1005];
int main() {
  int i, j, k, m, n, t;
  cin >> n;
  for (i = 0; i < 2 * n; i++) cin >> a[i];
  int sum = 0;
  int x = 0;
  for (i = 0; i < n * 2; i++) {
    x = 0;
    if (a[i] == 0) continue;
    for (j = i + 1; j < 2 * n; j++) {
      if (a[j] == 0) x++;
      if (a[i] == a[j]) {
        sum += j - i - 1 - x;
        a[i] = 0;
        a[j] = 0;
        break;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
