N = int(input())

A = []
for i in range(N):
    A.append(list(map(int,input().split())))
B = []
for i in range(N):
    B.append(list(map(int,input().split())))
C = []
for i in range(N-1):
    C.append(list(map(int,input().split())))

ans = 0
before = 9999
for i in range(N):
    ans += B[A[i]-1]
    if A[i]==before + 1:
        ans += c[i-1]

print(ans)