#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];
  int size, min, max, index, sum = 0;
  scanf("%d", &size);
  for (index = 0; index < size; index++) {
    scanf("%d", &arr[index]);
  }
  min = arr[0];
  max = arr[0];
  for (index = 0; index < size; index++) {
    minmax(&arr[index], size, &min, &max);
  }
  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)
movl   $0x0,-0x7f4(%rbp)
lea    0xead(%rip),%rdi
lea    -0x7e4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x7f0(%rbp)
mov    -0x7f0(%rbp),%eax
cmp    -0x7e4(%rbp),%eax
jge    11b0 <main+0x80>
movslq -0x7f0(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe69(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
jmp    1169 <main+0x39>
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7e8(%rbp)
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7ec(%rbp)
movl   $0x0,-0x7f0(%rbp)
mov    -0x7f0(%rbp),%eax
cmp    -0x7e4(%rbp),%eax
jge    1226 <main+0xf6>
movslq -0x7f0(%rbp),%rax
lea    -0x7e0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x7e4(%rbp),%esi
lea    -0x7e8(%rbp),%rdx
lea    -0x7ec(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
jmp    11d2 <main+0xa2>
mov    -0x7e8(%rbp),%eax
add    -0x7ec(%rbp),%eax
mov    %eax,-0x7f4(%rbp)
mov    -0x7f4(%rbp),%esi
lea    0xdbb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e8,%rsp
lea    0xebb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11da <main+0xaa>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe98(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
add    $0x4,%r15
cmp    %rsi,%rbx
jl     1170 <main+0x40>
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    %eax,0x8(%rsp)
mov    %eax,%ecx
test   %esi,%esi
jle    11da <main+0xaa>
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <minmax@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
add    $0x4,%r12
cmp    %rsi,%rbx
jl     11b0 <main+0x80>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%eax
jmp    11da <main+0xaa>
add    %ecx,%eax
lea    0xe1d(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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
store i32 0, i32* %1
store i32 0, i32* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %6
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%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)
br label %18
18: ; preds = %13
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %9
21: ; preds = %9
%22 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%23 = load i32, i32* %22
store i32 %23, i32* %4
%24 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %24
store i32 %25, i32* %5
store i32 0, i32* %6
br label %26
26: ; preds = %36, %21
%27 = load i32, i32* %6
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %3
%35 = call i32 @minmax(i32* %33, i32 %34, i32* %4, i32* %5)
br label %36
36: ; preds = %30
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %26
39: ; preds = %26
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = add nsw i32 %40, %41
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %43)
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 %36
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
store i32 %22, i32* %3
store i32 %22, i32* %4
%23 = icmp sgt i32 %17, 0
br i1 %23, label %24, label %36
24: ; preds = %20, %24
%25 = phi i64 [ %29, %24 ], [ 0, %20 ]
%26 = phi i32 [ %30, %24 ], [ %17, %20 ]
%27 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %25
%28 = call i32 @minmax(i32* %27, i32 %26, i32* %3, i32* %4)
%29 = add nuw nsw i64 %25, 1
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %24, label %33
33: ; preds = %24
%34 = load i32, i32* %3
%35 = load i32, i32* %4
br label %36
36: ; preds = %0, %33, %20
%37 = phi i32 [ %35, %33 ], [ %22, %20 ], [ undef, %0 ]
%38 = phi i32 [ %34, %33 ], [ %22, %20 ], [ undef, %0 ]
%39 = add nsw i32 %37, %38
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %39)
ret i32 0
}