{"problem":{"name":"Buffet","description":{"content":"Takahashi went to an all-you-can-eat buffet with $N$ kinds of dishes and ate all of them (Dish $1$, Dish $2$, $\\ldots$, Dish $N$) once. The $i$\\-th dish $(1 \\leq i \\leq N)$ he ate was Dish $A_i$. When","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc140_b"},"statements":[{"statement_type":"Markdown","content":"Takahashi went to an all-you-can-eat buffet with $N$ kinds of dishes and ate all of them (Dish $1$, Dish $2$, $\\ldots$, Dish $N$) once.\nThe $i$\\-th dish $(1 \\leq i \\leq N)$ he ate was Dish $A_i$.\nWhen he eats Dish $i$ $(1 \\leq i \\leq N)$, he gains $B_i$ satisfaction points.\nAdditionally, when he eats Dish $i+1$ just after eating Dish $i$ $(1 \\leq i \\leq N - 1)$, he gains $C_i$ more satisfaction points.\nFind the sum of the satisfaction points he gained.\n\n## Constraints\n\n*   All values in input are integers.\n*   $2 \\leq N \\leq 20$\n*   $1 \\leq A_i \\leq N$\n*   $A_1, A_2, ..., A_N$ are all different.\n*   $1 \\leq B_i \\leq 50$\n*   $1 \\leq C_i \\leq 50$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $...$ $A_N$\n$B_1$ $B_2$ $...$ $B_N$\n$C_1$ $C_2$ $...$ $C_{N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc140_b","tags":[],"sample_group":[["3\n3 1 2\n2 5 4\n3 6","14\n\nTakahashi gained $14$ satisfaction points in total, as follows:\n\n*   First, he ate Dish $3$ and gained $4$ satisfaction points.\n*   Next, he ate Dish $1$ and gained $2$ satisfaction points.\n*   Lastly, he ate Dish $2$ and gained $5 + 3 = 8$ satisfaction points."],["4\n2 3 4 1\n13 5 8 24\n45 9 15","74"],["2\n1 2\n50 50\n50","150"]],"created_at":"2026-03-03 11:01:14"}}