#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 */
long long gcd(long long, long long);
int /*<<< orphan*/ modPower(long long, long long, int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  long long int prod, tgcd, i, j, sum, temp, c, num, ele;
  scanf("%lld", &num);
  scanf("%lld", &ele);
  tgcd = ele;
  prod = ele;
  for (i = 1; i < num; i++) {
    scanf("%lld", &ele);
    prod = (prod * ele) % 1000000001;
    tgcd = gcd(tgcd, ele);
  }
  printf("%lld", modPower(prod, tgcd, 1000000001));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x48(%rbp),%rax
jge    11de <main+0x9e>
lea    0xe64(%rip),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
imul   -0x50(%rbp),%rax
mov    $0x3b9aca01,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1060 <gcd@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1187 <main+0x47>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x3b9aca01,%edx
call   1030 <modPower@plt>
mov    %eax,%esi
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%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    0xeab(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rbx
cmpq   $0x2,0x10(%rsp)
jl     11ed <main+0xad>
mov    $0x1,%r13d
lea    0xe77(%rip),%r15
lea    0x8(%rsp),%r12
movabs $0x89705f3ee868eb67,%rbp
5f 70 89
mov    %rbx,%r14
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rsi
imul   %rsi,%rbx
mov    %rbx,%rax
imul   %rbp
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca01,%rdx,%rax
sub    %rax,%rbx
mov    %r14,%rdi
call   1060 <gcd@plt>
mov    %rax,%r14
add    $0x1,%r13
cmp    0x10(%rsp),%r13
jl     11a0 <main+0x60>
jmp    11f0 <main+0xb0>
mov    %rbx,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3b9aca01,%edx
call   1030 <modPower@plt>
lea    0xdf9(%rip),%rdi
mov    %eax,%esi
call   1040 <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 = [5 x i8] c"%lld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %1
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %9)
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %10)
%13 = load i64, i64* %10
store i64 %13, i64* %3
%14 = load i64, i64* %10
store i64 %14, i64* %2
store i64 1, i64* %4
br label %15
15: ; preds = %28, %0
%16 = load i64, i64* %4
%17 = load i64, i64* %9
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %10)
%21 = load i64, i64* %2
%22 = load i64, i64* %10
%23 = mul nsw i64 %21, %22
%24 = srem i64 %23, 1000000001
store i64 %24, i64* %2
%25 = load i64, i64* %3
%26 = load i64, i64* %10
%27 = call i64 @gcd(i64 %25, i64 %26)
store i64 %27, i64* %3
br label %28
28: ; preds = %19
%29 = load i64, i64* %4
%30 = add nsw i64 %29, 1
store i64 %30, i64* %4
br label %15
31: ; preds = %15
%32 = load i64, i64* %2
%33 = load i64, i64* %3
%34 = call i32 @modPower(i64 %32, i64 %33, i32 1000000001)
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

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