$Gogi$, $Tapu$ and $Sonu$ are the elite members of $Tapu$ $Sena$. $Gogi$ is always stoned and asks absurd questions, But this time he asked a question which seems to be very serious and interesting. $Tapu$ wants to solve this question to impress $Sonu$. He  gave an array of length N to $Tapu$, $Tapu$ can perform the following operations exactly once:
- Remove any subarray from the given array given the resulting array formed after the removal is non-empty.    
- Reverse the whole array.
Remember you can’t shuffle the elements of the array.
Tapu needs to find out the maximum possible GCD of all the numbers in the array after applying the given operations exactly once. Tapu is very weak at programming, he wants you to solve this problem so that he can impress $Sonu$.

-----Input:-----
- The first line contains $T$, the number of test cases.
- For each test case
-FIrst line contains $N$.
- Last line contains $N$ numbers of the array. 

-----Output:-----
A single integer in a new line, maximum possible GCD. 

-----Constraints-----
- $1 \leq T \leq 10^2$
- $1 \leq N \leq 10^4$
- $1 \leq a[i] \leq 10^9$

Summation of N for all testcases is less than $10^6$ 

-----Sample Input 1:-----
1
1
2

-----Sample Output 1:-----
2

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
try:
    t = int(input())
    for _ in range(t):
        n = int(input())
        a = list(map(int, input().split()))
        gcd = max(a[0], a[-1])
        
        print(gcd)
except EOFError:pass

t=int(input())
for i in range(t):
    n = int(input())
    a=[int(x) for x in input().split()]
     
  
    print(max(a[0],a[-1])) 
  
# This code is contributed by mohit kumar 29 


# cook your dish here
from math import gcd
st=''
def func(n,l1):
    if n==1:
        return l1[0]
    elif n==2:
        return gcd(l1[0],l1[1])
    p=l1[0]
    m=p
    for i in range(1,n):
        g=gcd(p,l1[i])
        m=max(m,g)
        p=g
    p=l1[-1]
    m=max(m,p)
    for i in range(n-2,0,-1):
        g=gcd(l1[i],p)
        m=max(m,g)
        p=g
    return m



for _ in range(int(input())):
    #a,b=map(str,input().split())
    n = int(input())
    #s=input()
    l1=list(map(int,input().split()))
    #l2 = list(map(int, input().split()))
    #l1=input().split()
    #l2=input().split()
    st+=str(func(n,l1))+'\n'

print(st)
'''

'''


t=int(input())
for _ in range(t):
    n = int(input())
    arr = list(map(int, input().strip().split()))

    print(max(arr[0],arr[-1]))

# cook your dish here
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

def L():
    return list(map(int, stdin.readline().split()))

def In():
    return list(map(int, stdin.readline().split()))

def I():
    return int(stdin.readline())

P = 1000000007
for t in range(I()):
    n = I()
    arr = L()
    if arr[0] >= arr[n-1]:
        print(arr[0])
    else:
        print(arr[n-1])


for i in range(int(input())):
    n=input()
    l=list(map(int,input().split()))
    print(max(l[0],l[-1]))



for i in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    print(max(l[0],l[n-1]))

# cook your dish here
t = int(input())
for i in range(t):
    n = int(input())
    l = list(map(int, input().split()))
    e = 1
    for j in l:
        if j%e == 0:
            e = j
        else :
            break
    l.reverse()
    f = 1
    for s in l:
        if s%f == 0:
            f = s
        else:
            break
    if e>f:
        f = e
    print(f)

# cook your dish here
for i in range(int(input())):
    n=input()
    l=list(map(int,input().split()))
    m=l[0];x=l[-1]
    print(max(m,x))


import math
t=int(input())
for t1 in range(0,t):
	n=int(input())
	l=list(map(int,input().split()))
	
	if(n==1):
		print(*l)
	else:
		x=l[0]
		y=l[-1]
		l1=[]
		l2=[]
		for i in range(0,n):
			x=math.gcd(x,l[i])
			l1.append(x)
			if(x==1):
				break
		for j in range(n-1,-1,-1):
			y=math.gcd(y,l[j])
			l2.append(y)
			if(y==1):
				break
		#print(l1,l2)
		print(max(max(l1),max(l2)))

from math import gcd
t = int(input())
for _ in range(t):
    n = int(input())
    l = list(map(int, input().split()))
    print(max(l[0], l[n-1]))


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

t = int(input())
for u in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    ans =a[0]
    for i in a:
        h = gcd(ans, i)
        if(h>ans):
            ans = h
        else:
            break
    a.reverse()
    ans2 = a[0]
    for i in a:
        h = gcd(ans2, i)
        if(h>ans):
            ans2 = h
        else:
            break
    ans3 = gcd(ans, ans2)
    print(max(ans, max(ans2, ans3)))

t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    if a[0]>a[n-1]:
        print(a[0])
    else:
        print(a[n-1])


t = int(input())
for _ in range(t):
    n=int(input())
    f = [int(i) for i in input().split()]
    r=max(f[0], f[-1])
    print(r)


# cook your dish here
import math
T = int(input())

for _ in range(T):
    N = int(input())
    ar = input().split()
    m = int(ar[0])
    
    if int(ar[N-1]) > m:
        m = int(ar[N-1])
        
    print(m)

# cook your dish here
import math
T = int(input())

for _ in range(T):
    N = int(input())
    ar = input().split()
    m = int(ar[0])
    
    if int(ar[N-1]) > m:
        m = int(ar[N-1])
    '''x = m
    for i in range(1,N):
        x = math.gcd(x,int(ar[i])) 
        if m<x :
            m = x'''
        
            
    print(m)

a=int(input())
for i in range(0,a):
    b=int(input())
    c=list(map(int,input().split()))
    if(c[0]>c[len(c)-1]):
        print(c[0])
    else:
        print(c[len(c)-1])

t=int(input())
for i in range(0,t):
    n=int(input())
    l=list(map(int,input().split()))
    if n==1:
        print(l[0])
    else:    
        print(max(l[n-1],l[0]))

for _ in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    print((max(a[0],a[n-1])))# cook your dish here


# cook your dish here
t=int(input())
for _ in range(t):
    n=int(input())
    a=[int(x) for x in input().split()]
    if a[0]>a[-1]:
        print(a[0])
    else:
        print(a[-1])

from sys import stdin,stdout                           #
import math                                            #
import heapq                                           #
                                                       #
t = 1                                                  #
def aint():                                            #
	return int(input().strip())                        #
def lint():                                            #
	return list(map(int,input().split()))              #
def fint():                                            #
	return list(map(int,stdin.readline().split()))     #
                                                       #	
########################################################
 
def main():
	n=aint()
	l=lint()
	pre=[l[0]]
	suff=[l[-1]]
	for i in range(1,n):
		pre.append(math.gcd(pre[-1],l[i]))
	for i in range(n-2,-1,-1):
		suff.append(math.gcd(suff[-1],l[i]))
	print(max(max(pre),max(suff)))
t=aint()
########################################################
for i in range(t):                                     #
	main()                                             #

for _ in range(int(input())):
    n=int(input())
    a=list(map(int,input().split()))
    print(max(a[0],a[-1]))

t = int(input())
for _ in range(t):
    n = int(input())
    a = [int(i) for i in input().split()]
    print(max(a[0], a[n - 1]))

for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	print(max(li[0], li[-1]))

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))

    print(max(a[0], a[-1]))