#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long binary_exp(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a);
    }
    a = (a * a);
    b = b >> 1;
  }
  return ans;
}
bool comp(tuple<long long, long long, long long> a,
          tuple<long long, long long, long long> b) {
  if (get<0>(a) + get<1>(b) >= get<1>(a) + get<0>(b)) {
    return false;
  }
  { return true; }
}
vector<vector<int> > solved(1001, vector<int>(1001, 0));
void dfs(int x, int y, vector<string> v, int &ans, vector<vector<int> > &vis) {
  if (vis[x][y] == 0) {
    vis[x][y] = 1;
    int n = v.size();
    int m = v[0].size();
    if (x + 1 < n) {
      if (v[x + 1][y] == '*') {
        ans++;
      } else {
        dfs(x + 1, y, v, ans, vis);
      }
    }
    if (y + 1 < m) {
      if (v[x][y + 1] == '*') {
        ans++;
      } else {
        dfs(x, y + 1, v, ans, vis);
      }
    }
    if (x - 1 >= 0) {
      if (v[x - 1][y] == '*') {
        ans++;
      } else {
        dfs(x - 1, y, v, ans, vis);
      }
    }
    if (y - 1 >= 0) {
      if (v[x][y - 1] == '*') {
        ans++;
      } else {
        dfs(x, y - 1, v, ans, vis);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long T;
  T = 1;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; i++) {
      cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < 2 * n - 1; i++) {
      int j = i + 1;
      while (a[j] != a[i]) {
        j++;
      }
      while (a[j - 1] != a[i]) {
        swap(a[j - 1], a[j]);
        j--;
        ans++;
      }
      i++;
    }
    cout << ans << endl;
  }
  return 0;
}
