http://codeforces.com/contest/1107/problem/E
Vasya has a string ss of length nn consisting only of digits 0 and 1. Also he has an array aa of length nn .
Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue together the remaining parts (any of them can be empty). For example, if he erases substring 111 from string 111110 he will get the string 110. Vasya gets axax points for erasing substring of length xx .
Vasya wants to maximize his total points, so help him with this!
Input
The first line contains one integer nn (1≤n≤1001≤n≤100 ) — the length of string ss .
The second line contains string ss , consisting only of digits 0 and 1.
The third line contains nn integers a1,a2,…ana1,a2,…an (1≤ai≤1091≤ai≤109 ), where aiai is the number of points for erasin