n = int(input())
m = list(map(int, input().split()))
s = sorted(m)
print(s[0], s[-1])

d5f2a0c8c329bffb7d73fc80f95c2fcad5e8a52b
<mask token>

<mask token>
print(s[0], s[-1])

n = int(input())
m = list(map(int, input().split()))
s = sorted(m)
print(s[0], s[-1])
