N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = [True]*(1+N) j = 0 for i in range(N): if not ans[B[i]]: continue while A[j]!=B[i]: ans[A[j]] = False j += 1 j += 1 for i in range(1, N+1): if ans[i]: print(i)