n, k, *a = map(int, open(0).read().split()) print(max(a) - min(a))