{"raw_statement":[{"iden":"problem statement","content":"You are given a string $S$ of length $N$ consisting of `0` and `1`.\nA string $T$ of length $N$ consisting of `0` and `1` is a **good string** if and only if it satisfies the following condition:\n\n*   There is exactly one integer $i$ such that $1 \\leq i \\leq N - 1$ and the $i$\\-th and $(i + 1)$\\-th characters of $T$ are the same.\n\nFor each $i = 1,2,\\ldots, N$, you can choose whether or not to perform the following operation once:\n\n*   If the $i$\\-th character of $S$ is `0`, replace it with `1`, and vice versa. The cost of this operation, if performed, is $C_i$.\n\nFind the minimum total cost required to make $S$ a good string."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $S$ is a string of length $N$ consisting of `0` and `1`.\n*   $1 \\leq C_i \\leq 10^9$\n*   $N$ and $C_i$ are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$S$\n$C_1$ $C_2$ $\\ldots$ $C_N$"},{"iden":"sample input 1","content":"5\n00011\n3 9 2 6 4"},{"iden":"sample output 1","content":"7\n\nPerforming the operation for $i = 1, 5$ and not performing it for $i = 2, 3, 4$ makes $S =$ `10010`, which is a good string. The cost incurred in this case is $7$, and it is impossible to make $S$ a good string for less than $7$, so print $7$."},{"iden":"sample input 2","content":"4\n1001\n1 2 3 4"},{"iden":"sample output 2","content":"0"},{"iden":"sample input 3","content":"11\n11111100111\n512298012 821282085 543342199 868532399 690830957 973970164 928915367 954764623 923012648 540375785 925723427"},{"iden":"sample output 3","content":"2286846953"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}