#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 Left(int, int *);
int Right(int, int, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int length = 0;
  int *array, i;
  int max = 0, product = 0;
  scanf("%d", &length);
  array = (int *)malloc(length * sizeof(int));
  for (i = 0; i < length; i++) {
    scanf("%d", &array[i]);
  }
  for (i = 1; i < length - 1; i++) {
    product = Left(i, array) * Right(i, length, array);
    if (product > max)
      max = product;
  }
  printf("%d", max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe85(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d3 <main+0x83>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe40(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x4e>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1239 <main+0xe9>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <Left@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <Right@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1226 <main+0xd6>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    122b <main+0xdb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11da <main+0x8a>
mov    -0x18(%rbp),%esi
lea    0xdbd(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xe9a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
cmpl   $0x0,0x4(%rsp)
jle    1204 <main+0xb4>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xe6d(%rip),%r15
mov    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%rbx
jl     11a0 <main+0x50>
xor    %ebp,%ebp
cmp    $0x3,%eax
jl     1206 <main+0xb6>
mov    $0x1,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <Left@plt>
mov    %eax,%r15d
mov    0x4(%rsp),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1030 <Right@plt>
imul   %r15d,%eax
cmp    %ebp,%eax
cmovg  %eax,%ebp
add    $0x1,%ebx
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     11d0 <main+0x80>
jmp    1206 <main+0xb6>
xor    %ebp,%ebp
lea    0xdf3(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 4
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %3
store i32 0, i32* %4
br label %14
14: ; preds = %24, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = load i32*, i32** %3
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %18
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %14
27: ; preds = %14
store i32 1, i32* %4
br label %28
28: ; preds = %48, %27
%29 = load i32, i32* %4
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, 1
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %51
33: ; preds = %28
%34 = load i32, i32* %4
%35 = load i32*, i32** %3
%36 = call i32 @Left(i32 %34, i32* %35)
%37 = load i32, i32* %4
%38 = load i32, i32* %2
%39 = load i32*, i32** %3
%40 = call i32 @Right(i32 %37, i32 %38, i32* %39)
%41 = mul nsw i32 %36, %40
store i32 %41, i32* %6
%42 = load i32, i32* %6
%43 = load i32, i32* %5
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %33
%46 = load i32, i32* %6
store i32 %46, i32* %5
br label %47
47: ; preds = %45, %33
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %28
51: ; preds = %28
%52 = load i32, i32* %5
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %52)
ret i32 0
}

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