import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedList; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> arr = new ArrayList<>();
String str = null;
int n = Integer.parseInt(in.readLine());
String[] s = in.readLine().split(" ");
for(int i = 0;i < n*2; i++){
arr.add(Integer.parseInt(s[i]));
}
int sum = 0;
int i = 0;
while(i < arr.size()){
int j = arr.lastIndexOf(arr.get(i));
sum = sum + j - i -1;
arr.remove(j);
i++;
}
System.out.println(sum);
}
}