#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 *, int *, int *, int *, int *, int *,
                         int *, int *);
int main() {
  int mods[8] = {2, 3, 5, 7, 11, 13, 17, 19};
  int lesser_needed[8] = {1, 2, 1, 1, 1, 1, 1, 1};
  for (int i = 2; i < 8; i++)
    for (int j = 0; j < i; j++)
      lesser_needed[i] *= mods[j];
  int values[8];
  scanf("%d %d %d %d %d %d %d %d", values, values + 1, values + 2, values + 3,
        values + 4, values + 5, values + 6, values + 7);
  int sum = 0;
  for (int i = 0; i < 8; i++)
    sum += (mods[i] - 1 - values[i]) * lesser_needed[i];
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x2,-0x54(%rbp)
cmpl   $0x8,-0x54(%rbp)
jge    11e4 <main+0xc4>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    11d1 <main+0xb1>
movslq -0x58(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x54(%rbp),%rax
imul   -0x50(%rbp,%rax,4),%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11a2 <main+0x82>
jmp    11d6 <main+0xb6>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1191 <main+0x71>
lea    -0x80(%rbp),%rsi
lea    -0x80(%rbp),%rdx
add    $0x4,%rdx
lea    -0x80(%rbp),%rcx
add    $0x8,%rcx
lea    -0x80(%rbp),%r8
add    $0xc,%r8
lea    -0x80(%rbp),%r9
add    $0x10,%r9
lea    -0x80(%rbp),%r11
add    $0x14,%r11
lea    -0x80(%rbp),%r10
add    $0x18,%r10
lea    -0x80(%rbp),%rax
add    $0x1c,%rax
lea    0xe19(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <scanf@plt>
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
cmpl   $0x8,-0x88(%rbp)
jge    12a0 <main+0x180>
movslq -0x88(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
sub    $0x1,%eax
movslq -0x88(%rbp),%rcx
sub    -0x80(%rbp,%rcx,4),%eax
movslq -0x88(%rbp),%rcx
imul   -0x50(%rbp,%rcx,4),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    124e <main+0x12e>
mov    -0x84(%rbp),%esi
lea    0xdab(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x10(%rsp),%r9
lea    0x14(%rsp),%r10
lea    0x18(%rsp),%r11
lea    0x1c(%rsp),%rax
sub    $0x8,%rsp
lea    0xede(%rip),%rdi
lea    0x8(%rsp),%rsi
push   %rax
push   %r11
push   %r10
call   1040 <scanf@plt>
add    $0x20,%rsp
mov    0x4(%rsp),%eax
add    %eax,%eax
add    (%rsp),%eax
mov    $0x4,%ecx
sub    0x8(%rsp),%ecx
mov    $0x6,%edx
sub    0xc(%rsp),%edx
lea    (%rcx,%rcx,2),%ecx
mov    %edx,%esi
shl    $0x5,%esi
sub    %edx,%esi
sub    %edx,%esi
movdqa 0xe6c(%rip),%xmm0
psubd  0x10(%rsp),%xmm0
movdqa 0xe6e(%rip),%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq 0xe6d(%rip),%xmm0
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
add    %esi,%edx
lea    (%rdx,%rcx,2),%esi
sub    %eax,%esi
add    $0x5,%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"%d %d %d %d %d %d %d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%5 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%11 = call i32 @scanf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = mul i32 %13, -2
%15 = sub i32 %14, %12
%16 = add i32 %15, 5
%17 = load i32, i32* %5
%18 = sub i32 4, %17
%19 = mul nsw i32 %18, 6
%20 = load i32, i32* %6
%21 = sub i32 6, %20
%22 = mul nsw i32 %21, 30
%23 = bitcast i32* %7 to <4 x i32>*
%24 = load <4 x i32>, <4 x i32>* %23
%25 = sub <4 x i32> <i32 10, i32 12, i32 16, i32 18>, %24
%26 = mul nsw <4 x i32> %25, <i32 210, i32 2310, i32 30030, i32 510510>
%27 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %26)
%28 = add nsw i32 %27, %22
%29 = add nsw i32 %28, %19
%30 = add nsw i32 %29, %16
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
ret i32 0
}