from math import sqrt
n=int(input())
nums=list(map(int,input().split()))
num_list=[]
for num in nums:
if int(sqrt(num))**2!=num:
num_list.append(num)
else:
continue
max_num=max(num_list)
print(max_num)
from math import sqrt
n=int(input())
nums=list(map(int,input().split()))
num_list=[]
for num in nums:
if int(sqrt(num))**2!=num:
num_list.append(num)
else:
continue
max_num=max(num_list)
print(max_num)