#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 */
scalar_t__ abs(int);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int n;
  scanf("%d", &n);
  fgetc(stdin);
  char temps[257];
  fgets(temps, 257, stdin);
  int found = 0;
  int result = 0x7fffffff;
  int numBytes = 0;
  for (int i = 0; i < n; ++i) {
    int num, bytes;
    sscanf(temps + numBytes, "%d %n", &num, &bytes);
    numBytes += bytes;
    if (num > 0 && num == -result) {
      found = 1;
      result = num;
    } else if (abs(num) < abs(result)) {
      found = 1;
      result = num;
    }
  }
  if (found)
    printf("%d\n", result);
  else
    printf("0\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    $0x101,%esi
call   1060 <fgets@plt>
movl   $0x0,-0x114(%rbp)
movl   $0x7fffffff,-0x118(%rbp)
ff ff 7f
movl   $0x0,-0x11c(%rbp)
movl   $0x0,-0x120(%rbp)
mov    -0x120(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c0 <main+0x160>
lea    -0x110(%rbp),%rdi
movslq -0x11c(%rbp),%rax
add    %rax,%rdi
lea    0xe0a(%rip),%rsi
lea    -0x124(%rbp),%rdx
lea    -0x128(%rbp),%rcx
call   1070 <sscanf@plt>
mov    -0x128(%rbp),%eax
add    -0x11c(%rbp),%eax
mov    %eax,-0x11c(%rbp)
cmpl   $0x0,-0x124(%rbp)
jle    125c <main+0xfc>
mov    -0x124(%rbp),%eax
xor    %ecx,%ecx
sub    -0x118(%rbp),%ecx
cmp    %ecx,%eax
jne    125c <main+0xfc>
movl   $0x1,-0x114(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x118(%rbp)
jmp    12a7 <main+0x147>
mov    -0x124(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,-0x130(%rbp)
mov    -0x118(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
cmp    %rcx,%rax
jge    12a2 <main+0x142>
movl   $0x1,-0x114(%rbp)
mov    -0x124(%rbp),%eax
mov    %eax,-0x118(%rbp)
jmp    12a7 <main+0x147>
jmp    12ac <main+0x14c>
mov    -0x120(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x120(%rbp)
jmp    11d2 <main+0x72>
cmpl   $0x0,-0x114(%rbp)
je     12e6 <main+0x186>
mov    -0x118(%rbp),%esi
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f4 <main+0x194>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
lea    0xe78(%rip),%rdi
lea    0x18(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x2e4f(%rip),%rbx
mov    (%rbx),%edi
call   1060 <fgetc@plt>
mov    (%rbx),%edx
lea    0x20(%rsp),%rdi
mov    $0x101,%esi
call   1070 <fgets@plt>
cmpl   $0x0,0x18(%rsp)
jle    1278 <main+0x108>
movl   $0x7fffffff,0xc(%rsp)
7f
xor    %ebp,%ebp
lea    0xe36(%rip),%r12
lea    0x14(%rsp),%r15
lea    0x1c(%rsp),%r13
xor    %r14d,%r14d
movl   $0x0,0x10(%rsp)
jmp    1205 <main+0x95>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x1,0x10(%rsp)
mov    %edi,0xc(%rsp)
add    $0x1,%ebp
cmp    0x18(%rsp),%ebp
jge    125d <main+0xed>
movslq %r14d,%r14
lea    (%rsp,%r14,1),%rdi
add    $0x20,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
call   1080 <sscanf@plt>
add    0x1c(%rsp),%r14d
mov    0x14(%rsp),%edi
test   %edi,%edi
jle    1235 <main+0xc5>
mov    0xc(%rsp),%eax
neg    %eax
cmp    %eax,%edi
je     11f0 <main+0x80>
call   1040 <abs@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
call   1040 <abs@plt>
cmp    %rax,%rbx
jge    11fc <main+0x8c>
movl   $0x1,0x10(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0xc(%rsp)
jmp    11fc <main+0x8c>
cmpl   $0x0,0x10(%rsp)
je     1278 <main+0x108>
lea    0xd9e(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1284 <main+0x114>
lea    0xd8e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d %n\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [257 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* @stdin
%8 = call i32 @fgetc(i32 %7)
%9 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 257, i32 %10)
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %49
14: ; preds = %0
%15 = bitcast i32* %3 to i8*
%16 = bitcast i32* %4 to i8*
br label %19
17: ; preds = %41
%18 = icmp eq i32 %42, 0
br i1 %18, label %49, label %47
19: ; preds = %14, %41
%20 = phi i32 [ 0, %14 ], [ %44, %41 ]
%21 = phi i32 [ 0, %14 ], [ %28, %41 ]
%22 = phi i32 [ 2147483647, %14 ], [ %43, %41 ]
%23 = phi i32 [ 0, %14 ], [ %42, %41 ]
%24 = sext i32 %21 to i64
%25 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 %24
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%27 = load i32, i32* %4
%28 = add nsw i32 %27, %21
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 0
%31 = sub nsw i32 0, %22
%32 = icmp eq i32 %29, %31
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %41, label %34
34: ; preds = %19
%35 = call i64 @abs(i32 %29)
%36 = call i64 @abs(i32 %22)
%37 = icmp slt i64 %35, %36
%38 = load i32, i32* %3
%39 = select i1 %37, i32 1, i32 %23
%40 = select i1 %37, i32 %38, i32 %22
br label %41
41: ; preds = %34, %19
%42 = phi i32 [ 1, %19 ], [ %39, %34 ]
%43 = phi i32 [ %29, %19 ], [ %40, %34 ]
%44 = add nuw nsw i32 %20, 1
%45 = load i32, i32* %1
%46 = icmp slt i32 %44, %45
br i1 %46, label %19, label %17
47: ; preds = %17
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %51
49: ; preds = %0, %17
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
ret i32 0
}