#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);
scalar_t__ scanf(char *, int *);
int main() {
  int N = 0, a = 0, sum = 0;
  while (scanf("%d", &N)) {
    if (N == 0)
      break;
    else {
      while (N > 0) {
        scanf("%d", &a);
        sum += a;
        N--;
      }
      printf("%d\n", sum);
      N = 0, a = 0, sum = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11cc <main+0xac>
cmpl   $0x0,-0x8(%rbp)
jne    116d <main+0x4d>
jmp    11cc <main+0xac>
jmp    1172 <main+0x52>
cmpl   $0x0,-0x8(%rbp)
jle    11a3 <main+0x83>
lea    0xe7d(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1172 <main+0x52>
mov    -0x10(%rbp),%esi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xebd(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     11e1 <main+0xc1>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     11e1 <main+0xc1>
lea    0xe97(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0xe8e(%rip),%r15
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
test   %eax,%eax
jle    11af <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
add    0xc(%rsp),%ebp
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
cmp    $0x1,%eax
jg     1190 <main+0x70>
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     11e1 <main+0xc1>
mov    0x8(%rsp),%eax
test   %eax,%eax
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %26, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %27
12: ; preds = %8
br label %13
13: ; preds = %16, %12
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, %18
store i32 %20, i32* %4
%21 = load i32, i32* %2
%22 = add nsw i32 %21, -1
store i32 %22, i32* %2
br label %13
23: ; preds = %13
%24 = load i32, i32* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %26
26: ; preds = %23
br label %5
27: ; preds = %11, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = icmp eq i64 %5, 0
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %29, label %10
10: ; preds = %0, %21
%11 = phi i32 [ %26, %21 ], [ %7, %0 ]
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10, %13
%14 = phi i32 [ %17, %13 ], [ 0, %10 ]
%15 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = add nsw i32 %16, %14
%18 = load i32, i32* %1
%19 = add nsw i32 %18, -1
store i32 %19, i32* %1
%20 = icmp sgt i32 %18, 1
br i1 %20, label %13, label %21
21: ; preds = %13, %10
%22 = phi i32 [ 0, %10 ], [ %17, %13 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 0, i32* %1
store i32 0, i32* %2
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%25 = icmp eq i64 %24, 0
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 0
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %29, label %10
29: ; preds = %21, %0
ret i32 0
}