Ksusha is a beginner coder. Today she starts studying arrays. She has array a_1, a_2, ..., a_{n}, consisting of n positive integers.

Her university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help her and find the number!


-----Input-----

The first line contains integer n (1 ≤ n ≤ 10^5), showing how many numbers the array has. The next line contains integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9) — the array elements.


-----Output-----

Print a single integer — the number from the array, such that all array elements are divisible by it. If such number doesn't exist, print -1.

If there are multiple answers, you are allowed to print any of them.


-----Examples-----
Input
3
2 2 4

Output
2

Input
5
2 1 3 1 6

Output
1

Input
3
2 3 5

Output
-1

Difficulty: interview

Starter code:

Solutions:
input()
a = [int(x) for x in input().split()]
b = min(a)
print(-1 if any(x % b for x in a) else b)


input()
a = list(map(int, input().split()))
b = min(a)
for i in a:
  if i % b:
    print(-1)
    break
else:
  print(b)

n, t = int(input()), list(map(int, input().split()))
k = min(t)
print(-1 if any(i % k for i in t) else k)


n=int(input())
lis=input().split()
for i in range(len(lis)):
    lis[i]=int(lis[i])
m=min(lis)
check=1
for i in range(len(lis)):
    if lis[i]%m!=0:
        check=0
if check==0:
    print(-1)
else:
    print(m)


import sys
import math

n = int(sys.stdin.readline())
an = [int(x) for x in (sys.stdin.readline()).split()]

vmin = 1000000001

for i in an:
    if(i < vmin):
        vmin = i

for i in an:
    if(i % vmin != 0):
        print(-1)
        return
    
print(vmin)  

n = int(input())
a = list(map(int, input().split()))

a.sort()

t = a[0]
for x in a:
    if x % a[0] != 0:
        t = -1

print(t)

x = int(input())
ve = list(map(int , input().split()))
mn = min(int(i) for i in ve)
for i in range(0 , x ):
    if ve[i] % mn != 0:
        print("-1")
        return

print(mn)

n = int(input())
data = list(map(int, input().split()))
small = min(data)
for x in data:
    if x % small != 0:
        print(-1)
        import sys; return
print(small)


def f():
	input()
	a = list(map(int,input().split(' ')))
	m = min(a)
	for i in a:
		if i % m != 0:
			print(-1)
			break
	else:
		print(m)
f()

from fractions import gcd
n, a = int(input()), list(map(int, input().split()))
v = a[0]
for ai in a:
    v = gcd(v, ai)
print(v if v in a else -1)

from collections import defaultdict, deque, Counter, OrderedDict
from math import gcd
def main():
    n = int(input())
    g,d = 0,set()
    for i in map(int,input().split()):
        if g == 0: g = i
        else:
            g = gcd(g,i)
        d.add(i)
    print(g if g in d else -1)






def __starting_point():
    """sys.setrecursionlimit(400000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()"""
    main()
__starting_point()

I=input
I()
a=list(map(int,I().split()))
x=min(a)
print([x,-1][any(i%x for i in a)])

def main():
    from math import gcd
    input()
    s = set(map(int, input().split()))
    x = a = s.pop()
    for b in s:
        a = gcd(a, b)
        if a == 1:
            break
    s.add(x)
    print(a if a in s else -1)


def __starting_point():
    main()

__starting_point()

from fractions import gcd

n = int(input())
a = input().split()
a = [int(i) for i in a]

g = a[0]

for i in a:
	g = gcd(i, g)

if g in a:
	print(g)
else:
	print(-1)

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

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    ans = functools.reduce(gcd, a);
    if ans not in a:
        print(-1)
    else:
        print(ans)

def __starting_point():
    main()

__starting_point()

from fractions import gcd

def findGcd(data):
    g = data[0]
    for i in range (len(data)-1):
        g = gcd(g , data[i+1])
    
    return g

n = int(input())
a = [int(i) for i in input().split()]
gc = findGcd(a)
if gc in a:
    print(gc)
else:
    print(-1)


n = int(input())
a = [int(i) for i in input().split()]
m = min(a)
f = 1
for i in a:
    if i % m != 0:
        print(-1)
        f = 0
        break
if f == 1:
    print(m)

I=input
I()
a=list(map(int,I().split()))
x=min(a)
print([x,-1][any(i%x for i in a)])

n=int(input())
a=[int(x) for x in input().split()]
def gcd(a,b):
	a,b=max(a,b),min(a,b)
	while True:
		if a%b==0:
			return b
		b=a%b
		a=b
if n==1:
	print(a[0])
	return
ans=max(a)
for i in range(1,n):
	temp=gcd(a[i],a[i-1])
	if temp<=ans:
		ans=temp
	if ans==1:
		break
for i in a:
	if i%ans!=0:
		print(-1)
		return
if ans in a:
	print(ans)
else:
	print(-1)

n = int(input())
v = list(map(int, input().split()))

v.sort()
for x in v:
    if(x % v[0] != 0):
        print(-1)
        return

print(v[0])







from sys import stdin
def read(): return list(map(int, stdin.readline().split()))

read()
a = list(read())
x = min(a)
for y in a:
  if y % x != 0:
    x = -1
    break

print(x)


from sys import stdin
from math import gcd
n = int(stdin.readline())
arr = list( map(int, stdin.readline().split() ) )
ans = arr[0]
for x in arr:
	ans = gcd(ans, x)
flag = False
for x in arr:
	flag |= (x == ans)
if( flag ): print(ans)
else: print(-1)

I=input

I()

a=list(map(int,I().split()))

x=min(a)

print([x,-1][any(i%x for i in a)])

n=int(input())
a=list(map(int,input().split()))
c=min(a)
for r in a:
    if r%c!=0:
        print('-1')
        quit()
print(c)