package main import "fmt" import "reflect" func log(items... interface{}) { fmt.Println(items...) } func bug(items... interface{}) { panic("bug " + fmt.Sprint(items...)) } func assert(condition bool, items... interface{}) { if !condition { panic("assertion failed: " + fmt.Sprint(items...)) } } func scanln(args... interface{}) { nargs := make([]interface{}, 0, len(args)) for _, arg := range args { switch reflect.TypeOf(arg).Kind() { case reflect.Slice: v := reflect.ValueOf(arg) n := v.Len() for i := 0; i < n; i++ { nargs = append(nargs, v.Index(i).Addr().Interface()) } default: nargs = append(nargs, arg) } } n, e := fmt.Scanln(nargs...) if e != nil { panic(e) } assert(n == len(nargs)) } func check(n, low, high int) { if n < low || n > high { bug("bad input: ", n, " not in range ", low, " to ", high) } } func main() { H := make([]int, 26) scanln(H) for _, h := range H { check(h, 1, 7) } var word string scanln(&word) max := 0 for _, c := range word { h := H[c - 'a'] if h > max { max = h } } fmt.Println(max * len(word)) }