#include <bits/stdc++.h>
using namespace std;
void READ(vector<long long> &v, long long n) {
  long long a;
  for (long long i = 0; i < n; i = i + 1) {
    cin >> a;
    v.push_back(a);
  }
}
void PRINT(vector<long long> &v) {
  long long a;
  for (long long i = 0; i < v.size(); i = i + 1) {
    cout << v[i] << " ";
  }
  cout << "\n";
}
long long power(long long k, long long n, long long m = 1000000007) {
  long long res = 1;
  while (n) {
    if (n % 2 != 0) {
      res = (res * k) % m;
    }
    k = (k * k) % m;
    n = n / 2;
  }
  return (res);
}
long long n, m, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::cout.unsetf(std::ios::floatfield);
  std::cout.precision(15);
  long long a, b, c, d, e, x, i, j, t, y, w, z, x1, y1, z1, f;
  double p, q, r, u;
  char ch, chr;
  cin >> n;
  vector<long long> v;
  READ(v, 2 * n);
  x = 0;
  for (i = 0; i < 2 * n;) {
    a = v[i];
    for (j = i + 1; j < 2 * n; j = j + 1) {
      if (v[i] == v[j]) {
        break;
      }
    }
    c = 0;
    while (j > i + 1) {
      swap(v[j], v[j - 1]);
      c++;
      j--;
    }
    x += c;
    i += 2;
  }
  cout << x;
}
