a = int(input()) b = int(input()) c = 1000 d = 1 for i in range(a): e = int(input()) if c > e: c = e if d < e: d = e print(d-c)