#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a = 0, b = 0, c = 0, m, n, min = 1, cou = 1;
  while (1) {
    scanf("%d", &a);
    if (a == 0) {
      break;
    }
    for (m = 1; m <= a; m++) {
      scanf("%d", &n);
      if (n > b) {
        c = b;
        b = n;
        min = cou;
        cou = m;
      } else if (n > c) {
        c = n;
        min = m;
      }
    }
    printf("%d\n", min);
    a = 0, b = 0, c = 0, m, n, min = 1, cou = 1;
  }
  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,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1171 <main+0x51>
jmp    1224 <main+0x104>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ed <main+0xcd>
lea    0xe75(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11bd <main+0x9d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11da <main+0xba>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11d5 <main+0xb5>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11da <main+0xba>
jmp    11df <main+0xbf>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <main+0x58>
mov    -0x1c(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rsp)
lea    0xec7(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     11ee <main+0xce>
lea    0xead(%rip),%r13
jmp    118c <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%ebp
lea    0xe97(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
movl   $0x0,(%rsp)
mov    %r13,%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     11ee <main+0xce>
test   %eax,%eax
jle    1160 <main+0x40>
mov    $0x1,%r14d
xor    %ebx,%ebx
mov    $0x1,%ebp
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11bf <main+0x9f>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r15d,%eax
cmovg  %eax,%r15d
cmovg  %ebx,%ebp
cmp    (%rsp),%ebx
jge    1165 <main+0x45>
add    $0x1,%ebx
mov    %r13,%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %r12d,%eax
jle    11b0 <main+0x90>
mov    %r14d,%ebp
mov    %ebx,%r14d
mov    %r12d,%r15d
mov    %eax,%r12d
cmp    (%rsp),%ebx
jl     11bf <main+0x9f>
jmp    1165 <main+0x45>
xor    %eax,%eax
add    $0x8,%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 = [4 x i8] c"%d\0A\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 i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %7
store i32 1, i32* %8
br label %9
9: ; preds = %0, %41
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %46
14: ; preds = %9
store i32 1, i32* %5
br label %15
15: ; preds = %38, %14
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%21 = load i32, i32* %6
%22 = load i32, i32* %3
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* %3
store i32 %25, i32* %4
%26 = load i32, i32* %6
store i32 %26, i32* %3
%27 = load i32, i32* %8
store i32 %27, i32* %7
%28 = load i32, i32* %5
store i32 %28, i32* %8
br label %37
29: ; preds = %19
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %6
store i32 %34, i32* %4
%35 = load i32, i32* %5
store i32 %35, i32* %7
br label %36
36: ; preds = %33, %29
br label %37
37: ; preds = %36, %24
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %15
41: ; preds = %15
%42 = load i32, i32* %7
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%44 = load i32, i32* %5
%45 = load i32, i32* %6
store i32 1, i32* %7
store i32 1, i32* %8
br label %9
46: ; preds = %13
ret i32 0
}

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