
fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val indexList = readLine()!!.split(" ").map { it.toInt() - 1 }
    val manzoku = readLine()!!.split(" ").map { it.toInt() }
    val manzokuPlus = readLine()!!.split(" ").map { it.toInt() }

    var prevIndex = -10
    var ans = 0
    for(i in indexList) {
        if(i - prevIndex == 1) {
            ans += manzokuPlus[i-1]
        }
        ans += manzoku[i]
        prevIndex = i
    }
    println(ans)
}

