fun main(args: Array<String>) {
    readLine()
    val order = readLine()!!.split(" ").map { it.toInt() - 1 }
    val value = readLine()!!.split(" ").map(String::toInt)
    val additionalValue = readLine()!!.split(" ").map(String::toInt) + 0

    val result = order.withIndex().fold(0) { r, o: IndexedValue<Int> ->
        r + value[o.value] + if (order.nextIsInOrder(o)) additionalValue[o.value] else 0
    }

    println(result)
}

fun List<Int>.nextIsInOrder(i: IndexedValue<Int>): Boolean {
    val nextIndex = i.index + 1
    return nextIndex < this.size && this[nextIndex] == i.value + 1
}