#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 argc, char const *argv[]) {
  int T;
  scanf("%d", &T);
  int N;
  for (int i_T = 0; i_T < T; i_T++) {
    scanf("%d", &N);
    int product = 1;
    int temp = 1;
    for (int i_N = 0; i_N < N - 1; i_N++) {
      scanf("%d", &temp);
      product = (product * temp) % 1234567;
    }
    printf("%lld\n", product);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11dc <main+0xbc>
lea    0xea0(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11bf <main+0x9f>
lea    0xe6a(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    $0x12d687,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117e <main+0x5e>
mov    -0x20(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <main+0x2d>
xor    %eax,%eax
add    $0x30,%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
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    11f4 <main+0xd4>
xor    %ebp,%ebp
lea    0xead(%rip),%r13
lea    0xc(%rsp),%r15
lea    0xea4(%rip),%r12
jmp    1183 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x14(%rsp),%ebp
jge    11f4 <main+0xd4>
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
movl   $0x1,0xc(%rsp)
mov    $0x1,%ebx
cmpl   $0x2,0x10(%rsp)
jl     1170 <main+0x50>
mov    $0x1,%ebx
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
imul   0xc(%rsp),%ebx
movslq %ebx,%rbx
imul   $0x6cb7688d,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x33,%rax
add    %ecx,%eax
imul   $0x12d687,%eax,%eax
sub    %eax,%ebx
add    $0x1,%r14d
mov    0x10(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r14d
jl     11b0 <main+0x90>
jmp    1170 <main+0x50>
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 = [6 x i8] c"%lld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %8
br label %13
13: ; preds = %36, %2
%14 = load i32, i32* %8
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
store i32 1, i32* %9
store i32 1, i32* %10
store i32 0, i32* %11
br label %19
19: ; preds = %30, %17
%20 = load i32, i32* %11
%21 = load i32, i32* %7
%22 = sub nsw i32 %21, 1
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = mul nsw i32 %26, %27
%29 = srem i32 %28, 1234567
store i32 %29, i32* %9
br label %30
30: ; preds = %24
%31 = load i32, i32* %11
%32 = add nsw i32 %31, 1
store i32 %32, i32* %11
br label %19
33: ; preds = %19
%34 = load i32, i32* %9
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %13
39: ; preds = %13
ret i32 0
}

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