#include <bits/stdc++.h>
using namespace std;
int num_pairs, people[2 * 101], bit[2 * 101];
bool checked[101];
long long cnt;
unordered_map<int, vector<int>> positions;
inline void update(int pos) {
  for (int i = pos; i <= 2 * num_pairs; i += (i & -i)) bit[i]++;
}
inline int query(int pos) {
  int res = 0;
  for (int i = pos; i > 0; i -= (i & -i)) res += bit[i];
  return res;
}
int main(int argc, const char* argv[]) {
  scanf("%d", &num_pairs);
  for (int i = 1; i <= 2 * num_pairs; i++) {
    scanf(" %d", &people[i]);
    positions[people[i]].push_back(i);
  }
  for (int i = 2 * num_pairs; i >= 2; i--) {
    if (checked[people[i]]) continue;
    checked[people[i]] = true;
    int current_position = i - query(i);
    int other = positions[people[i]][0];
    if (i == other) other = positions[people[i]][1];
    int current = other - query(other);
    if (abs(current_position - current) == 1) {
      continue;
    }
    cnt += (current_position - current - 1);
    update(other + 1);
  }
  cout << cnt;
  return 0;
}
