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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x7e4(%rbp)
mov    -0x7e4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a0 <main+0x70>
movslq -0x7e4(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe79(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    115c <main+0x2c>
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7e8(%rbp)
mov    -0x7e0(%rbp),%eax
mov    %eax,-0x7ec(%rbp)
movl   $0x0,-0x7e4(%rbp)
mov    -0x7e4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1211 <main+0xe1>
movslq -0x7e4(%rbp),%rax
lea    -0x7e0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x8(%rbp),%rsi
lea    -0x7e8(%rbp),%rdx
lea    -0x7ec(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    11c2 <main+0x92>
mov    -0x7ec(%rbp),%esi
add    -0x7e8(%rbp),%esi
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7e0,%rsp
lea    0xeb9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11ed <main+0xbd>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe96(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1170 <main+0x40>
mov    0x10(%rsp),%esi
mov    %esi,0xc(%rsp)
mov    %esi,0x8(%rsp)
mov    %esi,%ecx
test   %eax,%eax
jle    11ed <main+0xbd>
lea    0x10(%rsp),%r13
xor    %ebx,%ebx
lea    0x4(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <minmax@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     11c0 <main+0x90>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%esi
jmp    11ed <main+0xbd>
add    %ecx,%esi
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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