# -*- coding: utf-8 -*-

n = int(raw_input())
R_List = []
Max = 0
R_min = 0
for i in range(n):
    R_List.append(int(raw_input()))
    if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i])
print Max n = int(raw_input()) n int(raw_input()) int raw_input() raw_input R_List = [] R_List [] Max = 0 Max 0 R_min = 0 R_min 0 for i in range(n):
    R_List.append(int(raw_input()))
    if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i]) i range(n) range n R_List.append(int(raw_input())) R_List.append R_List append int(raw_input()) int raw_input() raw_input if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i]) i == 0 i 0 R_min = R_List[0] R_min R_List[0] R_List 0 elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
     i == 1 i 1 Max = R_List[1]-R_min Max R_List[1]-R_min R_List[1] R_List 1 R_min R_min = min(R_min, R_List[1]) R_min min(R_min, R_List[1]) min R_min R_List[1] R_List 1 Max = max(Max, R_List[i]-R_min) Max max(Max, R_List[i]-R_min) max Max R_List[i]-R_min R_List[i] R_List i R_min R_min = min(R_min, R_List[i]) R_min min(R_min, R_List[i]) min R_min R_List[i] R_List i print R_min = min(R_min, R_List[1]) min(R_min, R_List[1]) R_min Max = 0 0 Max R_min = 0 0 R_min R_min = min(R_min, R_List[i]) min(R_min, R_List[i]) R_min n = int(raw_input()) int(raw_input()) n R_min = R_List[0] R_List[0] R_min R_List = [] [] R_List Max = R_List[1]-R_min R_List[1]-R_min Max Max = max(Max, R_List[i]-R_min) max(Max, R_List[i]-R_min) Max
# -*- coding: utf-8 -*-

n = int(raw_input())
R_List = []
Max = 0
R_min = 0
for i in range(n):
    R_List.append(int(raw_input()))
    if i == 0:
        R_min = R_List[0]
    elif i == 1:
        Max = R_List[1]-R_min
        R_min = min(R_min, R_List[1])
    else:
        Max = max(Max, R_List[i]-R_min)
        R_min = min(R_min, R_List[i])
print Max