import fileinput as fi
IN = fi.input()

def INT():
    return int(IN.readline())

def INTS():
    return tuple(int(num) for num in IN.readline().split())

a = INT()
b = INT()
nums = INTS()

from collections import Counter
s = Counter(nums)
for n in nums:
    s[n] -= 1
    if a % n == 0 and s[a // n] != 0:
        print(*sorted((a//n, n)))
        exit(0)
    s[n] += 1
