#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, num = 1, min, max;
  scanf("%d", &size);
  scanf("%d", &arr[0]);
  min = arr[0];
  max = arr[0];
  while (num < size) {
    scanf("%d", &arr[num]);
    minmax(&arr[num], &size, &min, &max);
    num++;
  }
  printf("%d", min + max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x7e8(%rbp)
lea    0xead(%rip),%rdi
lea    -0x7e4(%rbp),%rsi
call   1040 <scanf@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7ec(%rbp)
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7f0(%rbp)
mov    -0x7e8(%rbp),%eax
cmp    -0x7e4(%rbp),%eax
jge    1200 <main+0xd0>
movslq -0x7e8(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe48(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x7e8(%rbp),%rax
lea    -0x7e0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x7e4(%rbp),%rsi
lea    -0x7ec(%rbp),%rdx
lea    -0x7f0(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e8(%rbp)
jmp    118a <main+0x5a>
mov    -0x7ec(%rbp),%esi
add    -0x7f0(%rbp),%esi
lea    0xded(%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   %r13
push   %r12
push   %rbx
sub    $0x7e8,%rsp
lea    0xeb8(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x10(%rsp),%esi
mov    %esi,0xc(%rsp)
mov    %esi,0x8(%rsp)
cmpl   $0x2,0x4(%rsp)
mov    %esi,%eax
jl     11d6 <main+0xa6>
lea    0x14(%rsp),%rbx
mov    $0x1,%ebp
lea    0xe78(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1050 <minmax@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11a0 <main+0x70>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%esi
add    %eax,%esi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 [500 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %10
store i32 %11, i32* %5
%12 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %12
store i32 %13, i32* %6
br label %14
14: ; preds = %18, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %24
%26 = call i32 @minmax(i32* %25, i32* %3, i32* %5, i32* %6)
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %14
29: ; preds = %14
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = add nsw i32 %30, %31
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
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 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%12 = load i32, i32* %10
store i32 %12, i32* %3
store i32 %12, i32* %4
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %27
15: ; preds = %0, %15
%16 = phi i64 [ %20, %15 ], [ 1, %0 ]
%17 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = call i32 @minmax(i32* %17, i32* %2, i32* %3, i32* %4)
%20 = add nuw nsw i64 %16, 1
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %24
24: ; preds = %15
%25 = load i32, i32* %3
%26 = load i32, i32* %4
br label %27
27: ; preds = %24, %0
%28 = phi i32 [ %26, %24 ], [ %12, %0 ]
%29 = phi i32 [ %25, %24 ], [ %12, %0 ]
%30 = add nsw i32 %28, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
ret i32 0
}