n=gets.to_i
as=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)
cs=gets.split.map(&:to_i)

# bcs
bcs=[]
n.times do |i|
  if cs[i] == false
    cs[i] == nil
  end
  bcs.push([bs[i],cs[i]])
end

abcs=[]

as.each do |a|
  abcs.push([a,bcs[a-1]])
end

sum=0
rem=[21,[0,0]]
abcs.each do |x|
  sum+=x[1][0]
  sum+=rem[1][1] if x[0]-rem[0]==1
  rem=x
end

p sum
