def f(L, pos): min_time = max([min(p, L + 1 - p) for p in pos]) max_time = max([max(p, L + 1 - p) for p in pos]) return min_time, max_time L = int(input()) N = int(input()) pos = list(map(int, input().split())) result = f(L, pos) print(*result)