#!/usr/bin/env python
#-*- coding:utf-8 -*-

N = int(raw_input())

R = [int(raw_input()) for _ in range(N)]

minR = R[0]
maxVal = -2000000000

for i in R[1::]:
    maxVal = max(maxVal,i - minR)
    minR = min(minR, i)

print maxVal N = int(raw_input()) N int(raw_input()) int raw_input() raw_input int(raw_input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(raw_input()) int raw_input() raw_input R = [int(raw_input()) for _ in range(N)] R [int(raw_input()) for _ in range(N)] minR = R[0] minR R[0] R 0 maxVal = -2000000000 maxVal -2000000000 for i in R[1::]:
    maxVal = max(maxVal,i - minR)
    minR = min(minR, i) i R[1::] R 1:: 1 maxVal = max(maxVal,i - minR) maxVal max(maxVal,i - minR) max maxVal i - minR i minR minR = min(minR, i) minR min(minR, i) min minR i print maxVal = max(maxVal,i - minR) max(maxVal,i - minR) maxVal R = [int(raw_input()) for _ in range(N)] [int(raw_input()) for _ in range(N)] R N = int(raw_input()) int(raw_input()) N maxVal = -2000000000 -2000000000 maxVal minR = R[0] R[0] minR minR = min(minR, i) min(minR, i) minR
#!/usr/bin/env python
#-*- coding:utf-8 -*-

N = int(raw_input())

R = [int(raw_input()) for _ in range(N)]

minR = R[0]
maxVal = -2000000000

for i in R[1::]:
    maxVal = max(maxVal,i - minR)
    minR = min(minR, i)

print maxVal