rt,全WA,求调
#include<iostream>
using namespace std;
const int N=1e5+10;
int n, top, ans, a[N], st[N], now[N]; bool v[N];
int main() {
scanf("%d", &n);
for(int i=1;i<=n+n;i++) scanf("%d", &a[i]);
for(int i=1;i<=n+n;i++) {
if(v[a[i]]) {
int cnt=0;
while(st[top]!=a[i]) ++ans, now[++cnt]=st[top--];
--top; while(cnt) st[++top]=now[cnt--];
}
else st[++top]=a[i], v[a[i]]=true;
}
printf("%d\n", ans);
return 0;
}