Row=int(input())
List=[]
for i in range(Row):
  List.append(list(map(int,input().split())))

bj=0
newlist=0
for j in List[0]:
  newlist += List[1][j-1]
  if j-bj==1: 
    newlist += List[2][j-2]
  bj=j

print(newlist)