the-confused-monk
Source: hackerearth
Difficulty: EASY

The Monk wants to teach all its disciples a lesson about patience, since they are always in a hurry to do something crazy. To teach them this, he gives them a list of N numbers, which may or may not be distinct. The students are supposed to solve a simple Mathematical equation based on the array of these N numbers.
g(x) - GCD (a[ 0 ], a[ 1 ], a[ 2 ]... a[n-1] )
f(x) - (a[ 0 ] * a[ 1 ] * a[ 2 ]... * a[n-1] )

The value of the MonkQuotient is: 10^9 + 7.

The equation to be solved is: ( f(x)^g(x) ) % MonkQuotient

Input constraints:
The first line of input will contain an integer — N. The next line will contain N integers denoting the elements of the list. 

Output constraints:
Print the required answer of the equation.

Constraints:
1 ≤ N ≤ 50 
1 ≤ Ai ≤ 10^3

SAMPLE INPUT
2
2 6

SAMPLE OUTPUT
144

Explanation

Here we can see that the product of the elements of array is 12 and the GCD of the array comes out to be 2 .
Thus the answer would be 12^2 which is 144.


mod=10**9+7
def gcd(a,b):
	while b!=0:
		a=a%b
		a,b=b,a
	return a
n=int(input())
a=list(map(int,input().split()))
gx=a[0]
for i in a[1:n]:
	gx=gcd(gx,i)
fx=1
for i in a:
	fx=(fx*i)%mod
ans=1
while gx>0:
	if gx&1:
		ans=(ans*fx)%mod
	fx=fx*fx
	fx=fx%mod
	gx/=2
print(ans)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = int(input())
arr = list(map(int,input().split(" ")))


def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)
		
def modpow(a,b,mod):
	ans = 1
	while b != 0:
		if b%2==1:
			ans = (ans*a)%mod
		a=(a*a)%mod
		b/=2
	return int(ans)
	
f = 1
g = arr[n-1]
while n>0:
	g = gcd(g,arr[n-1])
	f = f*arr[n-1]
	n-=1
print(modpow(f,g,int(1e9+7)))


from fractions import gcd

def hcfarray(array):
	result=array[0]
	for i in range(1,len(array)):
		result=gcd(result,array[i])
	return result
	
MonkQuotient=10**9+7
array=[]
output=0
hcf=0
mul=1
size=int(input())
array=input().split()
array=[int(i) for i in array]
size=len(array)
if(size==1):
	mul=array[0]
	hcf=array[0]
elif(size==2):
	mul=array[0]*array[1]
	hcf=gcd(array[0],array[1])   
else:
	for i in array:
		mul*=i
	hcf=hcfarray(array)

output=(mul**hcf)%MonkQuotient
print(output)



def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

n = int(input())
storage = []
ans = 1

storage = list(map(int, input().split()))
g = storage[0]
for item in storage:
	g = gcd(item, g)
	ans *= item

print(((ans**g) % ((10**9)+7)))


def gcd(a):
	if(len(a)==1):
		return a
	else:
		x = a[0]
		y = a[1]
		z = a[1:]
		while x:
			x,y=y%x,x
        z[0]=y
        return gcd(z)

def f(a):
	t=1;
	for i in a:
		t*=i
	return t
	
N = int(input())
a = list(map(int,input().split()))
g = gcd(a)
g1 = g[0]
f1= f(a)

x =(f1**g1)%(10**9 + 7)
print(x)


def gcd(a,b):
	if b==0:
		return a
	return gcd(b,a%b)

t=eval(input())
a=list(map(int,input().split()))
g=a[0]
p=g
mod=pow(10,9)+7
for i in range(1,t):
	g=gcd(a[i],g)
	p=p*a[i]
print(pow(p,g,mod))
	


from fractions import gcd
from functools import reduce
n = input()
l = [int(i) for i in input().split()]
f=reduce(lambda x, y: x*y, l)
g = reduce(gcd,l)
print((f**g)%1000000007)


from functools import reduce
def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)
n = input()
l = [int(i) for i in input().split()]
f=reduce(lambda x, y: x*y, l)
g = reduce(gcd,l)
print((f**g)%1000000007)


def mul(arr):
	length = len(arr)
	counter = 0
	mul = 1
	while(counter < length):
		mul = mul * arr[counter]
		counter += 1
	return mul
def gcd(k):
	k.sort()
	lowest = k[0]
	length = len(k)
	counter = 0
	while(counter < length):
		if k[counter] % lowest != 0 :
			counter = 0
			lowest = lowest - 1
			continue
		counter += 1
	return lowest
a = eval(input())
count = 0
arr = []
q = 1000000007
String = input()
k = String.split(" ")
while count < a:
	m = int(k[count])
	arr.append(m)
	count += 1
g = gcd(arr)
m = mul(arr)
print(pow(m, g) % q)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
from fractions import gcd
gc=0
ans =1
num = int(input())	
arr = list(map(int,input().split()))

mq=1000000007
for i in arr:
	gc = gcd(gc,i)
	ans = (ans*(i%mq))%mq

ans = pow(ans,gc,mq)
print(ans)




def gcd(a, b):
	x = int(a)
	y = int(b)
	
	while y != 0:
		(x, y) = (y, x % y)
	return x
def summ(arr):
	add = 1
	for i in arr:
		add = add * int(i)
	return add

if __name__ == '__main__':
	T = int(input())
	num = input().split()
	i = 1
	k = int(num[0])
	while i < len(num):
	   # print("in")
		k = gcd(k,num[i])
		i += 1
	#print(k)
	n = summ(num)
	#print(n)
	print((n**k)%(1000000000 +7))

	
		


def Gcd(a,b):
	if b%a == 0:
		return a
	else:
		return Gcd(b%a,a)

C = 1000000007
N = int(input())
A = [int(x) for x in input().split()]

if N==1:
	gx = A[0]
else:
	temp = A[0]
	for i in range(N):
		temp = Gcd(temp,A[i])
	gx = temp
	
X = 1
for i in range(N):
	X*=A[i]
	X%=C

ans = 1
a   = X 
while (gx!=0):
	if gx%2 == 1:
		ans*=a
		ans%=C
	a*=a
	a%=C
	gx = gx/2
print(ans)

		
	
		


from functools import reduce
def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)
n = input()
l = [int(i) for i in input().split()]
f=reduce(lambda x, y: x*y, l)
g = reduce(lambda x,y: gcd(x,y),l)
print((f**g)%1000000007)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n=input()
n=int(n)
a=list(map(int,input().split()))
m_a=a[0]
f=1
for j in a:
	f*=j
	if j<=m_a:
		m_a=j

g=0
for k in range(1,m_a+1):
	count=0
	for l in a:
		if l%k!=0:
			break
		else:
			count+=1
	if count==len(a):
		g=k
if g==0:
	g=1
print(pow(f,g)%(1000000007))	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def GCD(A, B) :
	while B :
		A, B = B, A%B
	return A
N = eval(input())
A = [int(i) for i in input().split()]
g = A[0]
f = A[0]
for i in range(1, len(A)) :
	g = GCD(g, A[i])
	f = f * A[i]
print(pow(f, g, (10 ** 9 + 7)))


from functools import reduce
tam=eval(input())
arr=input()
arr=arr.rsplit()
arr=list(map(int,arr))
def GCD(a, b):

	if b == 0:
		return a
	else:
		return GCD(b, a % b)
f=reduce(lambda x, y: x*y, arr)
g=reduce(GCD, arr)
monk=(10**9)+7
print(((f**g)%monk))


def gcd(a):
	if(len(a)==1):
		return a
	else:
		x = a[0]
		y = a[1]
		z = a[1:]
		while x:
			x,y=y%x,x
        z[0]=y
        return gcd(z)

def f(a):
	t=1;
	for i in a:
		t*=i
	return t
	
N = int(input())
a = list(map(int,input().split()))
g = gcd(a)
g1 = g[0]
f1= f(a)

x =(f1**g1)%(10**9 + 7)
print(x)