import strutils, sequtils, math

discard stdin.readLine.parseInt()
let a = stdin.readLine.split().mapIt(it.parseInt())
let b = stdin.readLine.split().mapIt(it.parseInt())
let c = stdin.readLine.split().mapIt(it.parseInt())

iterator additional(a, b, c: seq[int]): int =
  for x, y in a:
    if x > 0:
      yield b[y - 1]
    else:
      if a[y - 1] == a[y - 2]:
        yield b[y - 1] + c[y - 2]

var r = 0
for i in additional(a, b, c):
  r.inc(i)

echo sum(b) + r