import sys prices = [*map(int, sys.stdin.read().strip().split())] n, prices = prices[0], prices[1:] mi, mx = prices[0], -99999999999 for i, e in enumerate(prices[1:], start=1): mx = max(mx, e - mi) mi = min(mi, e) print(max(0, mx))