#include <iostream>
#include <stdio.h>

using namespace std;

int main(){

    int n ;
    cin >> n;
    int house_f = n;
    int house_s = 0;
    int counter = 0;
    int array [n];
    for(int i=0 ; i<2*n ; i++){
        cin >> array[i];
    }
    for(int i= house_s ; i<n ; i++){
        int count = n - i;
        for(int j=house_f ; j< (2*n) - 1 ; j++){     
            if(array[i] != array[j]){
                count++;
            }else{
                break;
            }
        }
        counter += count ;
    }

    cout << counter ;
    return 0;
}