<reponame>c-yan/yukicoder<filename>yc21/yc21.py
N = int(input())
K = int(input())
n = [int(input()) for _ in range(N)]

n.sort()
print(n[-1] - n[0])

N = int(input())
K = int(input())
n = [int(input()) for _ in range(N)]

n.sort()
print(n[-1] - n[0])