#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int alpha[26], i;
  for (i = 0; i < 26; i++) {
    scanf("%d ", &alpha[i]);
  }
  char word[11];
  scanf("%s", word);
  int len = -1;
  for (i = 0; '\0' != word[i]; i++) {
    if (len < alpha[word[i] - 'a']) {
      len = alpha[word[i] - 'a'];
    }
  }
  printf("%d", len * i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x1a,-0x74(%rbp)
jge    116e <main+0x4e>
movslq -0x74(%rbp),%rax
lea    -0x70(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1139 <main+0x19>
lea    -0x7f(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x7f(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     11ee <main+0xce>
mov    -0x84(%rbp),%eax
movslq -0x74(%rbp),%rcx
movsbl -0x7f(%rbp,%rcx,1),%ecx
sub    $0x61,%ecx
movslq %ecx,%rcx
cmp    -0x70(%rbp,%rcx,4),%eax
jge    11db <main+0xbb>
movslq -0x74(%rbp),%rax
movsbl -0x7f(%rbp,%rax,1),%eax
sub    $0x61,%eax
cltq
mov    -0x70(%rbp,%rax,4),%eax
mov    %eax,-0x84(%rbp)
jmp    11e0 <main+0xc0>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1191 <main+0x71>
mov    -0x84(%rbp),%esi
imul   -0x74(%rbp),%esi
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xed2(%rip),%r14
xor    %ebx,%ebx
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x34(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x38(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x3c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x40(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x44(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x48(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x4c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x50(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x54(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x58(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x5c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x60(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x64(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x68(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x6c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x70(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x74(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xd47(%rip),%rdi
lea    0x5(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x5(%rsp),%cl
test   %cl,%cl
je     1300 <main+0x1e0>
mov    $0xffffffff,%ebx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movsbq %cl,%rcx
mov    -0x174(%rsp,%rcx,4),%ecx
cmp    %ecx,%ebx
cmovl  %ecx,%ebx
movzbl 0x6(%rsp,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    12e0 <main+0x1c0>
imul   %eax,%ebx
lea    0xd00(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [26 x i32]
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 26
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %11
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %12)
br label %14
14: ; preds = %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %6
17: ; preds = %6
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 -1, i32* %5
store i32 0, i32* %3
br label %20
20: ; preds = %50, %17
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 0, %25
br i1 %26, label %27, label %53
27: ; preds = %20
%28 = load i32, i32* %5
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 97
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp slt i32 %28, %37
br i1 %38, label %39, label %49
39: ; preds = %27
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = sub nsw i32 %44, 97
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %46
%48 = load i32, i32* %47
store i32 %48, i32* %5
br label %49
49: ; preds = %39, %27
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %20
53: ; preds = %20
%54 = load i32, i32* %5
%55 = load i32, i32* %3
%56 = mul nsw i32 %54, %55
%57 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [26 x i32]
%2 = alloca [11 x i8]
%3 = bitcast [26 x i32]* %1 to i8*
%4 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
%6 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 2
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 3
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 4
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 5
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 6
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 7
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 8
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %20)
%22 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 9
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %22)
%24 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 10
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %24)
%26 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 11
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %26)
%28 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 12
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 13
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %30)
%32 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 14
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %32)
%34 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 15
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %34)
%36 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 16
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %36)
%38 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 17
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %38)
%40 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 18
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %40)
%42 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 19
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %42)
%44 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 20
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %44)
%46 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 21
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %46)
%48 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 22
%49 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %48)
%50 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 23
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %50)
%52 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 24
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %52)
%54 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 25
%55 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %54)
%56 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%57 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %56)
%58 = load i8, i8* %56
%59 = icmp eq i8 %58, 0
br i1 %59, label %77, label %60
60: ; preds = %0, %60
%61 = phi i64 [ %70, %60 ], [ 0, %0 ]
%62 = phi i8 [ %72, %60 ], [ %58, %0 ]
%63 = phi i32 [ %69, %60 ], [ -1, %0 ]
%64 = sext i8 %62 to i64
%65 = add nsw i64 %64, -97
%66 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = icmp slt i32 %63, %67
%69 = select i1 %68, i32 %67, i32 %63
%70 = add nuw nsw i64 %61, 1
%71 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 0
br i1 %73, label %74, label %60
74: ; preds = %60
%75 = trunc i64 %70 to i32
%76 = mul nsw i32 %69, %75
br label %77
77: ; preds = %74, %0
%78 = phi i32 [ %76, %74 ], [ 0, %0 ]
%79 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %78)
ret i32 0
}