ll n,a[3d5],c[2d5];{rd(n,a(2n));rep(i,n)c[a[i]-1]=i;a[0..n-1]=c[a[n..]-1];wt(inversion(n,a));}