import sys
s_max = -float('inf')
s = 0
n = int(input())
r = list(map(int, sys.stdin.read().split()))
for i in range(1, n):
	s = max(s, 0) + r[i] - r[i-1]
	s_max = max(s, s_max)
print(s_max) import sys sys s_max = -float('inf') s_max -float('inf') float('inf') float 'inf' s = 0 s 0 n = int(input()) n int(input()) int input() input r = list(map(int, sys.stdin.read().split())) r list(map(int, sys.stdin.read().split())) list map(int, sys.stdin.read().split()) map int sys.stdin.read().split() sys.stdin.read().split sys.stdin.read() sys.stdin.read sys.stdin sys stdin read split for i in range(1, n):
	s = max(s, 0) + r[i] - r[i-1]
	s_max = max(s, s_max) i range(1, n) range 1 n s = max(s, 0) + r[i] - r[i-1] s max(s, 0) + r[i] - r[i-1] max(s, 0) + r[i] max(s, 0) max s 0 r[i] r i r[i-1] r i-1 i 1 s_max = max(s, s_max) s_max max(s, s_max) max s s_max print(s_max) print s_max r = list(map(int, sys.stdin.read().split())) list(map(int, sys.stdin.read().split())) r s = max(s, 0) + r[i] - r[i-1] max(s, 0) + r[i] - r[i-1] s n = int(input()) int(input()) n s = 0 0 s s_max = -float('inf') -float('inf') s_max s_max = max(s, s_max) max(s, s_max) s_max
import sys
s_max = -float('inf')
s = 0
n = int(input())
r = list(map(int, sys.stdin.read().split()))
for i in range(1, n):
	s = max(s, 0) + r[i] - r[i-1]
	s_max = max(s, s_max)
print(s_max)
