import Foundation protocol FromIntMax { init(intmax: UIntMax, mul: IntMax) } extension Int: FromIntMax { init(intmax: UIntMax, mul: IntMax) { self = mul > 0 ? Int(intmax) : Int.init(truncatingBitPattern: ~intmax &+ 1); } } extension Int8: FromIntMax { init(intmax: UIntMax, mul: IntMax) { self = mul > 0 ? Int8(intmax) : Int8.init(truncatingBitPattern: ~intmax &+ 1); } } extension UInt64: FromIntMax { init(intmax: UIntMax, mul: IntMax) { self = intmax } } func readArray() -> [T] { var result = [T](); var current: UIntMax = 0 let line = readLine()!.unicodeScalars var mul: IntMax = 0 for uc in line { if uc == " " { if mul != 0 { result.append(T(intmax: current, mul: mul)) current = 0 mul = 0 } } else if uc == "-" { mul = -1 } else { if mul == 0 { mul = 1 } current = current * 10 + (UIntMax(uc.value) - 48) } } if mul != 0 { result.append(T(intmax: current, mul: mul)) } return result } func readInt() -> T { var current: UIntMax = 0 let line = readLine()!.unicodeScalars var mul: IntMax = 0 for uc in line { if uc == " " { if mul != 0 { return T(intmax: current, mul: mul) } } else if uc == "-" { mul = -1 } else { if mul == 0 { mul = 1 } current = current * 10 + (UIntMax(uc.value) - 48) } } return T(intmax: current, mul: mul) } extension String { func trim() -> String { return self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) } } func readGraph(n: Int, _ m: Int) -> [[Int]] { var g = [[Int]](count: n + 1, repeatedValue: []) var temp: [Int] for _ in 0.. Int { return a >= mod ? a - mod : a } struct ModInt { var value: Int init(_ v: Int) { value = v % mod } init(raw: Int) { value = raw } } func *(lhs: ModInt, rhs: Int) -> ModInt { return ModInt(lhs.value * rhs) } func *(lhs: ModInt, rhs: ModInt) -> ModInt { return ModInt(lhs.value * rhs.value) } func +(lhs: ModInt, rhs: Int) -> ModInt { return ModInt(lhs.value + rhs) } func +(lhs: ModInt, rhs: ModInt) -> ModInt { return ModInt(raw: fix(lhs.value + rhs.value)) } func +=(inout lhs: ModInt, rhs: ModInt) { lhs.value = fix(lhs.value + rhs.value) } let lowerA = 97 let upperA = 65 let zero = 48 func countOnes(a: UInt64) -> Int { var x = (a & 0x5555555555555555) + ((a & 0xaaaaaaaaaaaaaaaa) >> 1) x = (x & 0x3333333333333333) + ((x & 0xcccccccccccccccc) >> 2) x = (x & 0x0f0f0f0f0f0f0f0f) + ((x & 0xf0f0f0f0f0f0f0f0) >> 4) x = (x & 0x00ff00ff00ff00ff) + ((x & 0xff00ff00ff00ff00) >> 8) x = (x & 0x0000ffff0000ffff) + ((x & 0xffff0000ffff0000) >> 16) x = (x & 0x00000000ffffffff) + ((x & 0xffffffff00000000) >> 32) return Int(x) } func countOnes(a: UInt16) -> Int { var x = (a & 0x5555) + ((a & 0xaaaa) >> 1) x = (x & 0x3333) + ((x & 0xcccc) >> 2) x = (x & 0x0f0f) + ((x & 0xf0f0) >> 4) x = (x & 0x00ff) + ((x & 0xff00) >> 8) return Int(x) } //===================================================================== var a: [Int] = readArray() var s = Array(readLine()!.unicodeScalars.map { Int($0.value) - lowerA }) var mx = 0 for i in s { mx = max(mx, a[i]) } print(mx * s.count)