n = int(input())t=[]for i in range(n) : d=input() t.append(d)small = 1001m = -1for i in range(n) : if small > t[n] : small = t[n] if m < t[n] : m < t[n]s = m - smallprint(s)