#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 arr[500] = {0};
  int i = 0, size, min = 0, max = 0;
  int Sum = 0;
  scanf("%d", &size);
  for (; i < size; i++) {
    scanf("%d", &arr[i]);
  }
  max = arr[0];
  min = arr[0];
  minmax(arr, size, &min, &max);
  int sum = min + max;
  printf("%d", sum);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x7e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x7d0,%edx
call   1040 <memset@plt>
movl   $0x0,-0x7e4(%rbp)
movl   $0x0,-0x7ec(%rbp)
movl   $0x0,-0x7f0(%rbp)
movl   $0x0,-0x7f4(%rbp)
lea    0xe6c(%rip),%rdi
lea    -0x7e8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x7e4(%rbp),%eax
cmp    -0x7e8(%rbp),%eax
jge    11e7 <main+0xa7>
movslq -0x7e4(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe32(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    11a0 <main+0x60>
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7f0(%rbp)
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7ec(%rbp)
lea    -0x7e0(%rbp),%rdi
mov    -0x7e8(%rbp),%esi
lea    -0x7ec(%rbp),%rdx
lea    -0x7f0(%rbp),%rcx
call   1060 <minmax@plt>
mov    -0x7ec(%rbp),%eax
add    -0x7f0(%rbp),%eax
mov    %eax,-0x7f8(%rbp)
mov    -0x7f8(%rbp),%esi
lea    0xdc2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x7e0,%rsp
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
mov    $0x7d0,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe98(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11b1 <main+0x71>
xor    %ebp,%ebp
lea    0xe7d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     1190 <main+0x50>
mov    0x10(%rsp),%ebp
mov    %ebp,0x4(%rsp)
mov    %ebp,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1060 <minmax@plt>
mov    0x4(%rsp),%esi
add    0x8(%rsp),%esi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.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 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [500 x i32]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %11
23: ; preds = %11
%24 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %24
store i32 %25, i32* %6
%26 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%27 = load i32, i32* %26
store i32 %27, i32* %5
%28 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%29 = load i32, i32* %4
%30 = call i32 @minmax(i32* %28, i32 %29, i32* %5, i32* %6)
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = add nsw i32 %31, %32
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

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