#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*/ minmax(int *, int, int *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i = 0, n, arr[500];
  int minimal = -696969, maximal = 696969;
  do {
    scanf("%d", &n);
  } while (n > 500 || n < 1);
  while (i < n) {
    scanf("%d", &arr[i]);
    i++;
  }
  minmax(arr, n, &minimal, &maximal);
  printf("%d", minimal + maximal);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xfff55d77,-0x7e4(%rbp)
5d f5 ff
movl   $0xaa289,-0x7e8(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1f4,-0xc(%rbp)
mov    %al,-0x7e9(%rbp)
jg     118f <main+0x5f>
cmpl   $0x1,-0xc(%rbp)
setl   %al
mov    %al,-0x7e9(%rbp)
mov    -0x7e9(%rbp),%al
test   $0x1,%al
jne    115d <main+0x2d>
jmp    11a2 <main+0x72>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11da <main+0xaa>
movslq -0x8(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe39(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a2 <main+0x72>
lea    -0x7e0(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x7e4(%rbp),%rdx
lea    -0x7e8(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7e4(%rbp),%esi
add    -0x7e8(%rbp),%esi
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7e8,%rsp
movl   $0xfff55d77,0x8(%rsp)
ff
movl   $0xaa289,0x4(%rsp)
lea    0xeac(%rip),%r14
lea    0xc(%rsp),%rbx
mov    $0xfffffe0b,%ebp
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
add    %ebp,%eax
cmp    $0xfffffe0c,%eax
jb     1160 <main+0x30>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe7a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rsi
add    $0x4,%r15
cmp    %rsi,%rbx
jl     1190 <main+0x60>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1050 <minmax@plt>
mov    0x4(%rsp),%esi
add    0x8(%rsp),%esi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e8,%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 [500 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 -696969, i32* %5
store i32 696969, i32* %6
br label %7
7: ; preds = %15, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %9
9: ; preds = %7
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 500
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 1
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %7, label %17
17: ; preds = %15
br label %18
18: ; preds = %22, %17
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %18
29: ; preds = %18
%30 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 0
%31 = load i32, i32* %3
%32 = call i32 @minmax(i32* %30, i32 %31, i32* %5, i32* %6)
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = add nsw i32 %33, %34
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
ret i32 0
}

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