Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \ldots, Dish N) once.
The i-th dish (1 \leq i \leq N) he ate was Dish A_i.
When he eats Dish i (1 \leq i \leq N), he gains B_i satisfaction points.
Additionally, when he eats Dish i+1 just after eating Dish i (1 \leq i \leq N - 1), he gains C_i more satisfaction points.
Find the sum of the satisfaction points he gained.

-----Constraints-----
 - All values in input are integers.
 - 2 \leq N \leq 20
 - 1 \leq A_i \leq N
 - A_1, A_2, ..., A_N are all different.
 - 1 \leq B_i \leq 50
 - 1 \leq C_i \leq 50

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
B_1 B_2 ... B_N
C_1 C_2 ... C_{N-1}

-----Output-----
Print the sum of the satisfaction points Takahashi gained, as an integer.

-----Sample Input-----
3
3 1 2
2 5 4
3 6

-----Sample Output-----
14

Takahashi gained 14 satisfaction points in total, as follows:
 - First, he ate Dish 3 and gained 4 satisfaction points.
 - Next, he ate Dish 1 and gained 2 satisfaction points.
 - Lastly, he ate Dish 2 and gained 5 + 3 = 8 satisfaction points.

Difficulty: introductory

Starter code:

Solutions:
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if(A[i] == A[i-1]+1 and i != 0):
        ans += C[A[i]-2]
print(ans)

N = int(input())
A,B,C = [list(map(int, input().split())) for _ in range(3)]

ans = 0

for i in range(N-1):
    if A[i+1] == A[i] + 1:
        ans += C[A[i]-1]

print(sum(B) + ans)

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

S = 0
for i in range(N-1):
    if A[i+1] == A[i] + 1:
        S += B[A[i]-1] + C[A[i]-1]
    else:
        S += B[A[i]-1]

S += B[A[N-1]-1]
print(S)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)

for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]

print(ans)

n = int(input())

an = list(map(int,input().split()))
bn = list(map(int,input().split()))
cn = list(map(int,input().split()))
sat = sum(bn)

for x in range(n-1):
    if an[x+1] == an[x] + 1:
        sat += cn[an[x]-1]

print(sat)


N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if i > 0 and A[i] == A[i-1] + 1:
        ans += C[A[i]-2]
print(ans)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
    if a[i+1]-a[i]==1:
        ans+=c[a[i]-1]
print(ans)

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)
for i in range(len(A)-1):
    if A[i] + 1 == A[i+1]:
        ans += C[A[i]-1]

print(ans)

N = int(input())
lsA = list(map(int,input().split()))
lsB = [0]+list(map(int,input().split()))
lsC = [0]+list(map(int,input().split()))
sumB = sum(lsB)
for i in range(N-1):
    if lsA[i]+1 == lsA[i+1]:
        sumB += lsC[lsA[i]]
print(sumB)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    num = a[i] - 1
    ans += b[num]

    if i == 0:
        continue
    elif a[i - 1] + 1 == a[i]:
        ans += c[num - 1]

print(ans)


N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        x+=C[A[i]-1]
print(x)


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans += c[a[i]-1]
ans += sum(b)
print(ans)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
    s+=B[A[i]-1]
    if A[i]-A[i-1]==1 and i>0:
        s+=C[A[i]-2]
print(s)

n = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
c = [int(s) for s in input().split()]

ans = b[a[0] - 1]

for i in range(1, n):
    ans += b[a[i] - 1]
    if a[i] == a[i - 1] + 1:
        ans += c[a[i] - 2]

print(ans)

def L():
	return list(map(int, input().split()))

N = int(input())
A = L()
B = L()
C = L()
O = 0

for i in range(N):
	ai = A[i] - 1
	O += B[ai]
	if i > 0 and A[i] == A[i - 1] + 1:
		O += C[ai - 1]

print(O)

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

for i in range(n):
  if (i == 0):
    ans =b[a[0] - 1]
    y = a[0]
  else:
    x = a[i]
    if (x - y == 1):
      ans = ans + b[x - 1] + c[y - 1]
    else:
      ans = ans + b[x - 1]
    y = x

print(ans)


n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

ans = 0
for i in range(0, n):
    ans += b[a[i] - 1]
for i in range(0, n - 1):
    if a[i + 1] == a[i] + 1:
        ans += c[a[i] - 1]
print(ans)

n=int(input())
a=list(map(lambda x:int(x)-1, input().split()))
ans=sum(list(map(int,input().split())))
c=list(map(int,input().split()))

for i in range(n-1):
  if a[i]+1==a[i+1]:
    ans+=c[a[i]]

print(ans)


n= int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans=0

for i in range(0,n):
    ans += b[a[i]-1]


    if i>=1:
        if a[i]==a[i-1]+1:

            ans+=c[a[i]-2]


print(ans)


n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(n):
  ans += B[A[i]-1]
  if i<n-1 and A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

N = int(input())
Alst = list(map(int, input().split()))
Blst = list(map(int, input().split()))
Clst = list(map(int, input().split()))

ans = sum(Blst)

for i in range(N-1):
    if Alst[i] + 1 == Alst[i+1]:
        ans += Clst[Alst[i]-1]

print(ans)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
# 配列の添字をNと合わせる
B.insert(0,0)
C.insert(0,0)
satis = 0
tmp = 999
for i in range(N):
    satis += B[A[i]]
    if (tmp - A[i]) == -1:
        satis += C[tmp]
    tmp = A[i] #i+1かどうかを判定
print(satis)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

s = 0
for i in range(N):
    s += B[A[i] - 1]
    if i < N - 1:
        if A[i] + 1 == A[i + 1]:
            s += C[A[i] - 1]

print(s)

from typing import List


def answer(n: int, a: List[int], b: List[int], c: List[int]) -> int:
    satisfaction = sum(b)
    for i in range(1, n):
        previous = a[i - 1]
        if a[i] == previous + 1:
            satisfaction += c[previous - 1]

    return satisfaction


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    print((answer(n, a, b, c)))


def __starting_point():
    main()

__starting_point()

n= int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans=0

for i in range(0,n):
    ans += b[a[i]-1]


    if i>=1:
        if a[i]==a[i-1]+1:

            ans+=c[a[i]-2]


print(ans)


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = b[a[-1]-1]
for i in range(n-1):
  ans += b[a[i]-1]
  if a[i] + 1 == a[i+1]:
    ans += c[a[i]-1]
print(ans)

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
pre_a = -1

for a in A:
    ans += B[a-1]
    if a == pre_a + 1:
        ans += C[a-2]
    pre_a = a

print(ans)


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
for i in range(n-1):
  if a[i+1]-a[i]==1:
    ans+=c[a[i]-1]
    
print(ans+sum(b))

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[0]-1]
for i in range(1, N):
    ans += B[A[i]-1]
    if A[i]-A[i-1] == 1:
        ans += C[A[i-1]-1]

print(ans)

N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
  ans += B[A[i]-1]
  
  
for j in range(0, N-1):
  if A[j+1] == A[j] + 1:
    ans = ans + C[A[j]-1]
    
print(ans)
  


N = int(input())
liA = list(map(int, input().split()))
liB = list(map(int, input().split()))
liC = list(map(int, input().split()))

Manzoku = sum(liB)

for i in range(N):
    if i < N - 1:
        if liA[i+1] - liA[i] == 1:
            Manzoku += liC[liA[i] - 1]

print((Manzoku))

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
  x = A[i] - 1
  ans += B[x]
  if i >= 1 and A[i] == A[i-1] + 1:
    ans += C[A[i-1]-1]
print(ans)

N = int(input())
A = list((int(x) for x in input().split()))
B = list((int(x) for x in input().split()))
C = list((int(x) for x in input().split()))
bonus = 0
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    bonus += C[A[i]-1]
print(sum(B)+bonus)

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
count = sum(B)
for i in range(n-1):
  if A[i+1]-A[i]==1:
    count+=C[A[i]-1]
print(count)

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i != 0:
        if a[i] == a[i - 1] + 1:
            ans += c[a[i] - 2]
print(ans)


N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

ans=0

for i in range(N-1):
	now=A[i]
	next=A[i+1]
	ans+=B[now-1]
	if next==now+1:
		ans+=C[now-1]

ans+=B[A[N-1]-1]

print(ans)

n = int(input())
list_a = [int(i) for i in input().split()]
list_b = [int(j) for j in input().split()]
list_c = [int(k) for k in input().split()]
satisfied = 0
for i in range(0, len(list_a)):
    satisfied += list_b[list_a[i] - 1]
    if i > 0 and list_a[i] == list_a[i - 1] + 1:
        satisfied += list_c[list_a[i - 1] - 1]
print(satisfied)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0

for i in range(n):
  ans += B[A[i]-1]
  if(i > 0 and A[i] == A[i-1]+1):
    ans += C[A[i]-2]

print(ans)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
res = 0
for i in range(n - 1):
    res += B[i]
    if A[i] + 1 == A[i + 1]:
        res += C[A[i] - 1]
print((res + B[-1]))


N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

count = 0
for j in A:
    count += B[j-1]

#print(count)

for z in range(N-1):
    if A[z+1]- A[z] == 1:
        zz = A[z]
        count += C[zz-1]

print(count)
    
    


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(len(a)):
  ai=a[i]
  ans+=b[ai-1]
  if(ans!=b[ai-1]):
    if(ai==before+1):
      ans+=c[before-1]
  before=ai
print(ans)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0

for i in range(n):
  ans += b[i]
for j in range(n-1):
  if a[j] == a[j+1] -1:
    ans += c[(a[j]-1)]

print(ans)

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

S = 0
for i in range(N-1):
    if A[i+1] == A[i] + 1:
        S += B[A[i]-1] + C[A[i]-1]
    else:
        S += B[A[i]-1]

S += B[A[N-1]-1]
print(S)

# 問題：https://atcoder.jp/contests/abc140/tasks/abc140_a

n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
c = list(map(int, input().strip().split()))

res = b[a[0]-1]
for i in range(1, n):
    res += b[a[i]-1]
    if a[i] - a[i-1] == 1:
        res += c[a[i-1]-1]

print(res)


N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
cnt = 100
for i in range(N):
  if cnt + 1 == A[i]:
    ans += C[cnt-1]
  cnt = A[i]
  ans += B[A[i]-1]
  
print(ans)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# 配列の添字をNと合わせる
B.insert(0,0)
C.insert(0,0)
satis = 0
tmp = 999
for i in range(N):
    satis += B[A[i]]
    if (tmp - A[i]) == -1:
        satis += C[tmp]
    tmp = A[i] #i+1かどうかを判定
print(satis)

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
d=sum(B)
for i in range(n-1):
  if A[i+1]-A[i]==1:
    d+=C[A[i]-1]
print(d)

n = int(input())
a,b,c = [list(map(int,input().split())) for i in range(3)]
x = 0
d = -10
for i in range(n):
    y = b[a[i]-1]
    x += y
    if a[i]-1 == d:
        x+= c[d-1]
    d = a[i]
print(x)

n = int(input())
a = list(map(int, input().split()))
b = sum(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n-1):
  if a[i+1] - a[i] == 1:
    s += c[a[i] - 1]
print(b + s)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=b[a[i]-1]
    if i!=0:
        if a[i]==a[i-1]+1:
            ans+=c[a[i]-2]
print(ans)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

addans=0

for i in range(n-1) :
  if a[i]+1 == a[i+1] :
    addans += c[a[i]-1]
print(sum(b)+addans)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=0
s += sum(b)
for i in range(n-1):
    if a[i]+1==a[i+1]:
        s += c[a[i]-1]
print(s)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i < N-1 and A[i+1] - A[i] == 1: ans += C[A[i]-1]
    
print(ans)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=sum(b)
for i in range(n-1):
  if a[i]-a[i+1]==-1:
    d=d+c[a[i]-1]
print(d)

n=int(input())

a_list=[int(i) for i in input().split()]
b_list=[int(i) for i in input().split()]
c_list=[int(i) for i in input().split()]

satisfaction=0

for i in range(n):
    satisfaction+=b_list[a_list[i]-1]
    if i<n-1:
        
        if a_list[i+1]==a_list[i]+1:
            satisfaction+=c_list[a_list[i]-1]
            
print(satisfaction)


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

cnt=0

for i in range(n):
  d=a[i]-1
  cnt+=b[d]
  
for j in range(n-1):
  if a[j]+1==a[j+1]:
    cnt+=c[a[j]-1]

print(cnt)

def resolve():
    n = int(input())
    a = tuple(map(int, input().split()))
    b = tuple(map(int, input().split()))
    c = tuple(map(int, input().split()))
    before_dinner = a[0]
    ans = sum(b)
    for i in range(1,n):
        if a[i] - before_dinner==1:
            ans += c[before_dinner-1]
        before_dinner = a[i]
    print(ans)
resolve()

N=int(input())
d=[[int(s) for s in input().split()] for i in range(3)]
ans=0
for i in range(N):
    ans+=d[1][d[0][i]-1]
    if i<=N-2 and d[0][i+1]-d[0][i]==1:
        ans+=d[2][d[0][i]-1]
print(ans)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
food = 0
manzoku = 0
bonus = 0
before = 10*3
ans = 0
for i in range(n):
    food = a[i]
    manzoku = b[food-1]
    if food == before+1:
        bonus = c[food-2]
        ans += manzoku + bonus
    else:
        ans += manzoku
    before = food
print(ans)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = -1
num = sum(b)
for i in a:
    if i == m+1:
        num += c[m-1]
    m = i
print(num)

i = int(input())
 
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
res = sum(b)
 
for j in range(i-1):
    if a[j] + 1 == a[j+1]:
      res += c[a[j] - 1]
print(res)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = sum(b)
for i in range(n-1):
  if a[i]+1 == a[i+1]:
    s += c[a[i]-1]
print(s)

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
res = 0
for x in range(N-1):
  res += B[x]
  if A[x] + 1 == A[x+1]:
    res += C[A[x] - 1]
print(res + B[-1])

# ABC140
# Buffet
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ct = 0
h = 25
for i in range(n):
    ct += B[i]
    if h + 1 == A[i]:
        ct += C[h - 1]
        h = A[i]
    else:
        h = A[i]
print(ct)


N=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
S = 0

for i in range(N):
    S += B[A[i]-1]


for i in range(N-1):
    if A[i]-A[i+1] == -1:
        S += C[A[i]-1]
print(S)


n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=b[a[i]-1]
    if i>0:
        if a[i]==a[i-1]+1:
            ans+=c[a[i-1]-1]
print(ans)

n=int(input())
ans=0
l=[list(map(int,input().split())) for i in range(3)]
for i in range(1,n+1):
    ans+=l[1][l[0][i-1]-1]
    if i!=n and l[0][i]==l[0][i-1]+1:
        ans+=l[2][l[0][i-1]-1]
print(ans)

n=int(input());ans=0
a=[*map(int,input().split())]
b={i+1:j for i,j in enumerate(map(int,input().split()))}
c={i+1:j for i,j in enumerate(map(int,input().split()))}
ans+=b[a[0]]
for i in range(1,n):
  if a[i]-(a[i-1])==1:
    ans+=c[a[i-1]]
  ans+=b[a[i]]
print(ans)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  s+=B[A[i]-1]
  if i!=0 and A[i-1]+1==A[i]:
    s+=C[A[i]-2]
print(s)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
eat_bef=0
ans=0
for i in range(len(a)):
    ans+=b[a[i]-1]
    if i>=1:
        if eat_bef+1==a[i]:
            ans+=c[eat_bef-1]
    eat_bef=a[i]
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print(ans)

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(1,n):
  if a[i-1]+1 == a[i]:
    ans += c[a[i-1]-1]
print(ans)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    point = sum(b)

    for i in range(1,n):
        if a[i-1] +1 == a[i]:
            point += c[a[i-1]-1]


    print(point)

def __starting_point():
    main()
__starting_point()

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    total_score = sum(b)

    for i in range(1, n):
        prev = a[i - 1]
        if prev + 1 == a[i]:
            total_score += c[prev - 1]

    print(total_score)


def __starting_point():
    main()

__starting_point()

N = int(input())
A = list(map(int, input().split()))
A = list([x - 1 for x in A])
B = list(map(int, input().split()))
C = list(map(int, input().split()))
cnt = 0

for i in range(N):
    cnt += B[A[i]]
    if A[i] == A[i-1] + 1 and i != 0:
        cnt += C[A[i-1]]
print(cnt)




N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=B[A[0]-1]
mae=A[0]
for i in range(1,N):
    ans+=B[A[i]-1]
    if A[i]-mae==1:
        ans+=C[mae-1]
    mae=A[i]

print(ans)

N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
    ans += B[A[i]]
    if i > 1:
        if A[i] == A[i-1]+1:
            ans += C[A[i-1]]
print(ans)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i > 0 and A[i] - A[i-1] == 1: ans += C[A[i-1]-1]
    
print(ans)

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
res = b[a[0]-1]
for i in range(1,n):
  #print(i,res,a[i])
  res += b[a[i]-1]
  if a[i-1] + 1 == a[i]:
    res += c[a[i-1]-1]
print(res)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        d += c[a[i] - 1]
print(d + sum(b))

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sumB = sum(B)

cnt = []

for i in range(n-1):
    if A[i]+1 == A[i+1]:
        cnt.append(A[i]-1)

sumC = 0
for i in cnt:
    sumC += C[i]

print((sumB+sumC))


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
num = 0
for i in A:
    ans += B[i-1]
    if num != 0 and i - num == 1:
        ans += C[i-2]
    num = i
    
print(ans)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += B[A[i] - 1]
    if i>=1 and A[i] - A[i-1] == 1:
        ans += C[A[i-1] - 1]

print(ans)

N = int(input())
A_List = list(map(int,input().split()))
B_List = list(map(int,input().split()))
C_List = list(map(int,input().split()))
ans = 0

for i in range(len(A_List)):
    ans += B_List[A_List[i] - 1]
    if (i != 0) & (A_List[i] - A_List[i-1] == 1):
        ans += C_List[A_List[i-1]-1]
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = b[-1]
for i in range(n - 1):
    res += b[i]
    if a[i] + 1 == a[i + 1]:
        res += c[a[i] - 1]
print(res)

def mapt(fn, *args):
    return tuple(map(fn, *args))

def Input():
    return mapt(int, input().split(" "))

def main():
    n = int(input())
    a = Input()
    b = Input()
    c = Input()
    ans = 0
    for i in range(n-1):
        if a[i+1] - a[i] == 1:
            ans += c[a[i]-1]
    ans += sum(b)
    print(ans)
main()

N = int(input())
dishes = list(map(int, input().split()))
satisfaction = list(map(int, input().split()))
additional = list(map(int, input().split()))

res = 0

for i in range(N-1):
    res += satisfaction[i]

    if dishes[i] + 1 == dishes[i+1]:
        res += additional[dishes[i] - 1]

print((res + satisfaction[-1]))




kind = int(input())

table_1 = input().split(' ')
table_2 = input().split(' ')
table_3 = input().split(' ')
total = 0
for i in range(kind):
    total += int(table_2[i])
    
for j in range(kind-1):
    if int(table_1[j]) == int(table_1[j + 1]) - 1:
        total += int(table_3[int(table_1[j]) - 1])
print(total)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
prev = -1
for a in A:
    ans += B[a - 1]
    if prev == a - 1:
        ans += C[prev - 1]
    prev = a
print(ans)


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
su = 0
n1 = len(a)
for i in a:
    su += b[i-1]

for i in range(n1-1):
    if a[i] == a[i+1] -1:
        su += c[a[i]-1]

print(su)

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
x = -1

for i in A:
    ans += B[i-1]
    if x+1 == i:
        ans += C[x-1]
    x = i

print(ans)



N = int(input())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

ans = sum(B)
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        ans += C[A[i]-1]

print(ans)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
i = -2
for j in range(n):
    if a[j]-1 == i+1:
        ans += c[i]
    i = a[j] - 1
    ans += b[i]
print(ans)


N = int(input())

A =list(map(int,input().split()))
B =list(map(int,input().split()))
C =list(map(int,input().split()))


b=sum(B)

for i in range (N-1):
    if (A[i]+1==A[i+1]):
        b=b+C[A[i]-1]


print(b)


n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
satisfy=0
for i in range(n):
  satisfy+=b[a[i]-1]
  if i>=1 and a[i-1]+1==a[i]:
    satisfy+=c[a[i]-2]
print(satisfy)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

def main():
    score=0
    for i in range(N):
        score += B[A[i]-1]
        if A[i] == A[i-1] + 1 and i>=1:
            score += C[A[i-1]-1]

    return score
print(main())

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0]-1]

for i in range(1, N):
  ans += B[A[i]-1]
  if A[i] == A[i-1] + 1:
    ans += C[A[i-1]-1]
print(ans)