#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 main() {
  int n = 0;
  int x = 0;
  int i = 0;
  int soma = 0;
  scanf("%d", &n);
  if (n >= 0 && n <= 50) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &x);
      if (x < 0) {
        x = x * (-1);
      }
      if (x > 5000) {
        return 0;
      } else {
        soma = soma + x;
      }
    }
    printf("%d", soma);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11ec <main+0xcc>
cmpl   $0x32,-0x8(%rbp)
jg     11ec <main+0xcc>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d8 <main+0xb8>
lea    0xe77(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    11a3 <main+0x83>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1388,-0xc(%rbp)
jle    11bc <main+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <main+0xd3>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <main+0xaa>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1176 <main+0x56>
mov    -0x14(%rbp),%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
jmp    11f3 <main+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xec3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x32,%eax
ja     11ab <main+0x8b>
test   %eax,%eax
je     119b <main+0x7b>
xor    %ebp,%ebp
lea    0xea3(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
jns    1187 <main+0x67>
neg    %eax
mov    %eax,(%rsp)
cmp    $0x1388,%eax
ja     11ab <main+0x8b>
add    %eax,%ebx
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1170 <main+0x50>
jmp    119d <main+0x7d>
xor    %ebx,%ebx
lea    0xe5c(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %39
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 50
br i1 %11, label %12, label %39
12: ; preds = %9
store i32 1, i32* %4
br label %13
13: ; preds = %33, %12
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %36
17: ; preds = %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, -1
store i32 %23, i32* %3
br label %24
24: ; preds = %21, %17
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 5000
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* %1
br label %40
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = add nsw i32 %29, %30
store i32 %31, i32* %5
br label %32
32: ; preds = %28
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %13
36: ; preds = %13
%37 = load i32, i32* %5
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %40
39: ; preds = %9, %0
store i32 0, i32* %1
br label %40
40: ; preds = %27, %39, %36
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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 i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp ult i32 %6, 51
br i1 %7, label %8, label %29
8: ; preds = %0
%9 = icmp eq i32 %6, 0
br i1 %9, label %26, label %10
10: ; preds = %8, %21
%11 = phi i32 [ %22, %21 ], [ 0, %8 ]
%12 = phi i32 [ %23, %21 ], [ 1, %8 ]
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = sub nsw i32 0, %14
store i32 %17, i32* %2
br label %18
18: ; preds = %16, %10
%19 = phi i32 [ %17, %16 ], [ %14, %10 ]
%20 = icmp ugt i32 %19, 5000
br i1 %20, label %29, label %21
21: ; preds = %18
%22 = add nsw i32 %19, %11
%23 = add nuw nsw i32 %12, 1
%24 = load i32, i32* %1
%25 = icmp slt i32 %12, %24
br i1 %25, label %10, label %26
26: ; preds = %21, %8
%27 = phi i32 [ 0, %8 ], [ %22, %21 ]
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %18, %0, %26
ret i32 0
}