#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> A(2 * n);
  for (int i = (0); i < (2 * n); i++) {
    cin >> A[i];
  }
  long long cant = 0;
  long long tam = 2 * n;
  while (tam > 2) {
    int x = A[0];
    for (int i = (1); i < (tam); i++) {
      if (A[i] == x) {
        cant += i - 1;
        break;
      }
    }
    vector<int> tmp;
    for (int i = (0); i < (tam); i++) {
      if (A[i] != x) tmp.push_back(A[i]);
    }
    A = tmp;
    tam = (int)(A).size();
  }
  cout << cant << "\n";
}
