#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 atoi(char *);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main() {
  int n;
  scanf("%d", &n);
  fgetc(stdin);
  char temps[257];
  fgets(temps, 257, stdin);
  fprintf(stderr, "temps = %s\n", temps);
  char *token = strtok(temps, " ");
  int current = 0;
  while (token != NULL) {
    int n = atoi(token);
    if (current == 0) {
      current = n;
    } else if (abs(n) < abs(current)) {
      current = n;
    } else if (abs(n) == abs(current)) {
      if (n > current)
        current = n;
    }
    token = strtok(NULL, " ");
  }
  printf("%d\n", current);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    $0x101,%esi
call   1060 <fgets@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xe22(%rip),%rsi
call   1070 <fprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x118(%rbp)
movl   $0x0,-0x11c(%rbp)
cmpq   $0x0,-0x118(%rbp)
je     1302 <main+0x182>
mov    -0x118(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x120(%rbp)
cmpl   $0x0,-0x11c(%rbp)
jne    1248 <main+0xc8>
mov    -0x120(%rbp),%eax
mov    %eax,-0x11c(%rbp)
jmp    12e6 <main+0x166>
mov    -0x120(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,-0x128(%rbp)
mov    -0x11c(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x128(%rbp),%rax
cmp    %rcx,%rax
jge    1289 <main+0x109>
mov    -0x120(%rbp),%eax
mov    %eax,-0x11c(%rbp)
jmp    12e1 <main+0x161>
mov    -0x120(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,-0x130(%rbp)
mov    -0x11c(%rbp),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
cmp    %rcx,%rax
jne    12dc <main+0x15c>
mov    -0x120(%rbp),%eax
cmp    -0x11c(%rbp),%eax
jle    12d7 <main+0x157>
mov    -0x120(%rbp),%eax
mov    %eax,-0x11c(%rbp)
jmp    12dc <main+0x15c>
jmp    12e1 <main+0x161>
jmp    12e6 <main+0x166>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd1e(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x118(%rbp)
jmp    120a <main+0x8a>
mov    -0x11c(%rbp),%esi
lea    0xd02(%rip),%rdi
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   %rbx
sub    $0x118,%rsp
lea    0xe6c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x2e43(%rip),%rbx
mov    (%rbx),%edi
call   1050 <fgetc@plt>
mov    (%rbx),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x101,%esi
call   1060 <fgets@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
lea    0xe30(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strtok@plt>
test   %rax,%rax
je     1253 <main+0xd3>
xor    %ebx,%ebx
lea    0xe1a(%rip),%r14
jmp    1211 <main+0x91>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r14,%rsi
call   1090 <strtok@plt>
mov    %ebp,%ebx
test   %rax,%rax
je     1255 <main+0xd5>
mov    %rax,%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
test   %ebx,%ebx
je     1200 <main+0x80>
mov    %ebp,%edi
call   1030 <abs@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1030 <abs@plt>
cmp    %rax,%r15
jl     1200 <main+0x80>
mov    %ebp,%edi
call   1030 <abs@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1030 <abs@plt>
cmp    %ebx,%ebp
cmovle %ebx,%ebp
cmp    %rax,%r15
cmovne %ebx,%ebp
jmp    1200 <main+0x80>
xor    %ebp,%ebp
lea    0xdb5(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [12 x i8] c"temps = %s\0A\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [257 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* @stdin
%6 = call i32 @fgetc(i32 %5)
%7 = getelementptr inbounds [257 x i8], [257 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 257, i32 %8)
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%12 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %34, label %14
14: ; preds = %0, %30
%15 = phi i8* [ %32, %30 ], [ %12, %0 ]
%16 = phi i32 [ %31, %30 ], [ 0, %0 ]
%17 = call i32 @atoi(i8* %15)
%18 = icmp eq i32 %16, 0
br i1 %18, label %30, label %19
19: ; preds = %14
%20 = call i64 @abs(i32 %17)
%21 = call i64 @abs(i32 %16)
%22 = icmp slt i64 %20, %21
br i1 %22, label %30, label %23
23: ; preds = %19
%24 = call i64 @abs(i32 %17)
%25 = call i64 @abs(i32 %16)
%26 = icmp eq i64 %24, %25
%27 = icmp sgt i32 %17, %16
%28 = select i1 %26, i1 %27, i1 false
%29 = select i1 %28, i32 %17, i32 %16
br label %30
30: ; preds = %23, %19, %14
%31 = phi i32 [ %17, %14 ], [ %17, %19 ], [ %29, %23 ]
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %14
34: ; preds = %30, %0
%35 = phi i32 [ 0, %0 ], [ %31, %30 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %35)
ret i32 0
}