#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<long long> a(2 * n);
map<long long, int> Map;
long long ans = 0;
for (int i = 0; i < 2 * n; i++) {
cin >> a[i];
Map[a[i]] = i;
}
for (int i = 0; i < 2 * n; i += 2){
for (int j = Map[a[i]]; a[j - 1] != a[i]; j--) {
Map[a[j - 1]] = max(j , Map[a[j - 1]]);
swap(a[j], a[j - 1]);
ans++;
}
}
cout << ans << endl;
return 0;
}
963A - Alternating Sum | 1191B - Tokitsukaze and Mahjong |
1612G - Max Sum Array | 1459B - Move and Turn |
1006F - Xor-Paths | 706C - Hard problem |
304C - Lucky Permutation Triple | 1301C - Ayoub's function |
38E - Let's Go Rolling | 171G - Mysterious numbers - 2 |
1183C - Computer Game | 400C - Inna and Huge Candy Matrix |
417A - Elimination | 222A - Shooshuns and Sequence |
1736A - Make A Equal to B | 1736B - Playing with GCD |
887C - Solution for Cube | 1737C - Ela and Crickets |
1741C - Minimize the Thickness | 1741A - Compare T-Shirt Sizes |
1741D - Masha and a Beautiful Tree | 109B - Lucky Probability |
1741B - Funny Permutation | 1741E - Sending a Sequence Over the Network |
344B - Simple Molecules | 370A - Rook Bishop and King |
546E - Soldier and Traveling | 1741G - Kirill and Company |
1200B - Block Adventure | 1088B - Ehab and subtraction |