#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*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int n, i;
  scanf("%d", &n);
  long long item;
  scanf("%lld", &item);
  long long rev = 0, max = item, temp = item, count = 1;
  for (i = 1; i < n; i++) {
    scanf("%lld", &item);
    if (item < max) {
      max = item;
      count += 1;
    }
    if (temp >= rev) {
      rev = temp;
      count = 0;
    }
  }
  temp = max * count;
  if (temp >= rev)
    rev = temp;
  printf("%lld\n", rev);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xebb(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x1,-0x38(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11eb <main+0xcb>
lea    0xe76(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    11ba <main+0x9a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     11d8 <main+0xb8>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
jmp    11dd <main+0xbd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117a <main+0x5a>
mov    -0x28(%rbp),%rax
imul   -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     120e <main+0xee>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
xor    %r12d,%r12d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xeb8(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%r13
cmpl   $0x2,0xc(%rsp)
jl     11c2 <main+0xa2>
mov    $0x1,%r14d
mov    $0x1,%ebp
lea    0x10(%rsp),%r15
mov    %r13,%rbx
xor    %r12d,%r12d
nopl   0x0(%rax)
lea    0xe7c(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rax
xor    %ecx,%ecx
cmp    %rbx,%rax
setl   %cl
cmovl  %rax,%rbx
add    %rbp,%rcx
cmp    %r12,%r13
cmovge %r13,%r12
mov    $0x0,%ebp
cmovl  %rcx,%rbp
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jl     1180 <main+0x60>
jmp    11ca <main+0xaa>
mov    $0x1,%ebp
mov    %r13,%rbx
imul   %rbp,%rbx
cmp    %r12,%rbx
cmovl  %r12,%rbx
lea    0xe2c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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