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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119a <main+0x6a>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
lea    -0x7f0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe79(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <main+0x29>
mov    -0x7f0(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x7f0(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x7f0(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

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

LLVM IR (-O2):
@.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 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast [500 x i32]* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br label %12
12: ; preds = %0, %12
%13 = phi i64 [ 0, %0 ], [ %14, %12 ]
%14 = add nuw nsw i64 %13, 1
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 %13
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, %15
br i1 %19, label %12, label %20
20: ; preds = %12
%21 = trunc i64 %14 to i32
%22 = getelementptr inbounds [500 x i32], [500 x i32]* %4, i64 0, i64 0
%23 = load i32, i32* %22
store i32 %23, i32* %1
store i32 %23, i32* %2
%24 = call i32 @minmax(i32* %22, i32 %21, i32* %1, i32* %2)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%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
}