CodeEff/ECCO huggingface dataset:
# Original solution
import sys
import bisect
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w, n = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(int)
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        a -= 1
        b -= 1
        for j in range(max(1, a - 1), min(h-1, a + 2)):
            for k in range(max(1, b - 1), min(w-1, b + 2)):
                d[j, k] += 1
    ls = [0] * 10
    for k, v in sorted(list(d.items()), key=lambda x: x[1]):
        ls[v] += 1
    ls[0] = (h - 3 + 1) * (w - 3 + 1) - sum(ls)
    for i in range(10):
        print((ls[i]))


if __name__ == '__main__':
    slove()


# Optimized solution
import sys
import collections


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w, n = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(int)
    for _ in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        for i in range(-1, 2):
            for j in range(-1, 2):
                if 1 <= a-1+i < h-1 and 1 <= b-1+j < w-1:
                    d[a-1+i, b-1+j] += 1
    nd = []
    for k, v in list(d.items()):
        nd.append(v)
    nd = collections.Counter(nd)
    print(((h - 2) * (w - 2) - sum(nd.values())))
    for i in range(1, 10):
        print((nd[i]))


if __name__ == '__main__':
    solve()
# Original solution
from collections import Counter
H,W,N = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

blacks = Counter()
for y,x in src:
    for i in range(-1,2):
        if not 0 <= y+i < H: continue
        for j in range(-1,2):
            if not 0 <= x+j < W: continue
            blacks[(x+j, y+i)] += 1

ans = [0] * 10
for (x,y),v in blacks.items():
    if x<2 or y<2: continue
    ans[v] += 1
ans[0] = (H-2)*(W-2) - sum(ans[1:])
print(*ans,sep='\n')


# Optimized solution
import sys
input = sys.stdin.readline
H,W,N = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
from collections import defaultdict
dic = defaultdict(lambda: 0)
for y,x in AB:
    for dx in range(-1,2):
        for dy in range(-1,2):
            nx,ny = x+dx,y+dy
            if not 1 <= nx <= W: continue
            if not 1 <= ny <= H: continue
            dic[(nx,ny)] += 1

ans = [0] * 10
for (x,y),c in dic.items():
    if x==1 or x==W or y==1 or y==H: continue
    ans[c] += 1
s = sum(ans)
ans[0] = (W-2)*(H-2)-s

print(*ans, sep='\n')
# Original solution
import math

H, W, N = list(map(int, input().split()))
count = [0]*10
count[0] = (H-2)*(W-2)
rectmap=[]

#print(board)
for i in range(0,N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    al = max(a-1, 2)
    au = min(a+2, H)
    bl = max(b-1, 2)
    bu = min(b+2, W)

    for j in range(al, au):
        for k in range(bl, bu):
            rectmap.append([j-1, k-1])
##    for j in range(a-1, a+2):
##        for k in range(b-1, b+2):
##            if j>1 and j<H and k>1 and k<W:
##                rectmap.append([j-1, k-1])
#print(rectmap)
rectmap.sort()
while len(rectmap)!=0 :
    c = rectmap.count(rectmap[0])
    del rectmap[:c]
    count[c]+=1
    count[0]-=1
for i in range(0, 10):
    print((count[i]))    
#print(H,W,N)
#print(ab)


# Optimized solution
import math

H, W, N = list(map(int, input().split()))
count = [0]*10
count[0] = (H-2)*(W-2)
rectmap={}

#print(board)
for i in range(0,N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    ab = (a, b)
    al = max(a-1, 2)
    au = min(a+2, H)
    bl = max(b-1, 2)
    bu = min(b+2, W)

    for j in range(al, au):
        for k in range(bl, bu):
            if (j,k) in rectmap:
                rectmap[(j,k)] +=1
            else:
                rectmap[(j,k)] = 1
#            print(rectmap)
##    for j in range(a-1, a+2):
##        for k in range(b-1, b+2):
##            if j>1 and j<H and k>1 and k<W:
##                rectmap.append([j-1, k-1])
#print(rectmap)
for i in list(rectmap.values()):
    count[i]+=1
    count[0]-=1
for c in count:
    print(c)
#print(H,W,N)
#print(ab)
# Original solution
from collections import Counter
h, w, n = [int(i) for i in input().split()]
cnt = Counter()

vs = []
for i in range(-1, 2):
	for j in range(-1, 2):
		vs.append((i,j))

for _ in range(n):
	a, b = [int(i) for i in input().split()]
	for v in vs:
		aa = a + v[0]
		bb = b + v[1]
		if 2<=aa<=h-1 and 2<=bb<=w-1:
			cnt.update([(aa, bb)])


cnt2 = [0] * 10
cnt2[0] = (h-2)*(w-2)
for k in cnt:
	c = cnt[k]
	cnt2[c] += 1
	cnt2[0] -= 1

for i in cnt2:
	print(i)





# Optimized solution
from collections import Counter
h, w, n = [int(i) for i in input().split()]

vs = []
for i in range(-1, 2):
	for j in range(-1, 2):
		vs.append((i,j))
cnt = []
for _ in range(n):
	a, b = [int(i) for i in input().split()]
	for v in vs:
		aa = a + v[0]
		bb = b + v[1]
		if 2<=aa<=(h-1) and 2<=bb<=(w-1):
			cnt.append(aa*w+bb)

cnt = Counter(cnt)


cnt2 = [0] * 10
cnt2[0] = (h-2)*(w-2)
for k in cnt:
	c = cnt[k]
	cnt2[c] += 1
	cnt2[0] -= 1

for i in cnt2:
	print(i)
# Original solution
from collections import defaultdict as dd
H,W,N=list(map(int,input().split()))
ab = [tuple(map(int,input().split())) for _ in range(N)]
tpl = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]
edge_WtoB = dd(list)
edge_BtoB = dd(list)
node_B = set(ab)
node_W = set()
res = dd(int)
# 今見てるマスが黒
for a,b in ab:
    for s,t in tpl:
        tgt = (a+s,b+t)
        # 隣接マスも黒
        if tgt in node_B:
            if not (1 < a < H and 1 < b < W):
                continue
            edge_BtoB[(a,b)].append(tgt)
        # 隣接マスは白
        else:
            if not (1 < a + s < H and 1 < b + t < W):
                continue
            edge_WtoB[tgt].append((a,b))
            node_W.add(tgt)
for tgt in node_W:
    res[len(edge_WtoB[tgt])] += 1
for tgt in node_B:
    res[len(edge_BtoB[tgt])] += 1
zero = (H-2)*(W-2)
for j in range(1,10):
    zero -= res[j]
res[0] = zero
for j in range(10):
    print((res[j]))

# Optimized solution
from collections import defaultdict as dd
H,W,N=list(map(int,input().split()))
ab = [tuple(map(int,input().split())) for _ in range(N)]
tpl = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]
edge_WtoB = dd(int)
edge_BtoB = dd(int)
node_B = set(ab)
# node_W = set()
res = dd(int)
# 今見てるマスが黒
for a,b in ab:
    for s,t in tpl:
        tgt = (a+s,b+t)
        # 隣接マスも黒
        if tgt in node_B:
            if not (1 < a < H and 1 < b < W):
                continue
            edge_BtoB[(a,b)] += 1
        # 隣接マスは白
        else:
            if not (1 < a + s < H and 1 < b + t < W):
                continue
            edge_WtoB[tgt] += 1
            # node_W.add(tgt)
for val in list(edge_WtoB.values()):
    res[val] += 1
for val in list(edge_BtoB.values()):
    res[val] += 1
zero = (H-2)*(W-2)
for j in range(1,10):
    zero -= res[j]
res[0] = zero
for j in range(10):
    print((res[j]))
# Original solution
pos_black_mapping = {}
pos_num_mapping = {}
H, W, N = list(map(int, input().split()))
for i in range(N):
    a, b = list(map(int, input().split()))
    a, b = a-1, b-1
    pos_black_mapping[a, b] = 1
    for dy in range(-2, 3):
        for dx in range(-2, 3):
            na, nb = a+dx, b+dy
            if (0 <= na < H-2) and (0 <= nb < W-2):
                pos_num_mapping[na, nb] = 1

ans = [0 for _ in range(10)]
for a, b in list(pos_num_mapping.keys()):
    cnt = 0
    for dy in range(3):
        for dx in range(3):
            na, nb = a+dx, b+dy
            if (na, nb) in pos_black_mapping:
                cnt += 1
    ans[cnt] += 1
ans[0] = (W-2)*(H-2) - sum(ans[1:])
for v in ans:
    print(v)

# Optimized solution
pos_black_mapping = {}
pos_num_mapping = {}
H, W, N = list(map(int, input().split()))
for i in range(N):
    a, b = list(map(int, input().split()))
    a, b = a-1, b-1
    if (a, b) in pos_black_mapping:
        continue
    pos_black_mapping[a, b] = 1
    for da in range(-1, 2):
        for db in range(-1, 2):
            na, nb = a+da, b+db
            if (0 < na < H-1) and (0 < nb < W-1):
                if not (na, nb) in pos_num_mapping:
                    pos_num_mapping[na, nb] = 0
                pos_num_mapping[na, nb] += 1

ans = [0 for _ in range(10)]
for a, b in list(pos_num_mapping.keys()):
    ans[pos_num_mapping[a, b]] += 1
ans[0] = (W-2)*(H-2) - sum(ans[1:])
for v in ans:
    print(v)
# Original solution
import collections

h, w, n = list(map(int, input().split()))
pos = collections.defaultdict(lambda: collections.defaultdict(bool))
squares = collections.defaultdict(lambda: collections.defaultdict(bool))
for index in range(n):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    pos[a][b] = True
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] = True
counter = collections.Counter()
for y, xs in list(squares.items()):
    for x in xs:
        count = 0
        for i in range(3):
            for j in range(3):
                if pos[y + i][x + j]:
                    count += 1
        counter[count] += 1
print(((h - 2) * (w - 2) - sum(counter.values())))
for i in range(1, 10):
    print((counter[i]))

# Optimized solution
import collections

h, w, n = list(map(int, input().split()))
squares = collections.defaultdict(lambda: collections.defaultdict(int))
for index in range(n):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] += 1
counter = collections.Counter()
for y, xs in list(squares.items()):
    for x, count in list(xs.items()):
        counter[count] += 1
print(((h - 2) * (w - 2) - sum(counter.values())))
for i in range(1, 10):
    print((counter[i]))
# Original solution
import sys
from collections import defaultdict
input = sys.stdin.readline
H, W, N = list(map(int, input().split()))

board = defaultdict(int)
black = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    black.append((a - 1, b - 1))
    board[(a-1) * 10 ** 10 + (b - 1)] = 1

num = [0] * 10
for p in black:
    for ch in range(max(p[0] - 1, 1), min(p[0] + 2, H - 1)):
        for cw in range(max(p[1] - 1, 1), min(p[1] + 2, W - 1)):
            count = 0
            for h in range(ch - 1, ch + 2):
                for w in range(cw - 1, cw + 2):
                    if board[h * 10 ** 10 + w] == 1:
                        count += 1
            num[count] += 1
for i in range(1, 10):
    num[i] //= i
print(((H - 2) * (W - 2) - sum(num)))
for i in range(1, 10):
    print((num[i]))


# Optimized solution
import sys
from collections import defaultdict
input = sys.stdin.readline
H, W, N = list(map(int, input().split()))

board = defaultdict(int)
black = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    black.append((a - 1, b - 1))
    board[(a-1) * W + (b - 1)] = 1

num = [0] * 10
for p in black:
    for ch in range(max(p[0] - 1, 1), min(p[0] + 2, H - 1)):
        for cw in range(max(p[1] - 1, 1), min(p[1] + 2, W - 1)):
            count = 0
            for h in range(ch - 1, ch + 2):
                for w in range(cw - 1, cw + 2):
                    if board[h * W + w] == 1:
                        count += 1
            num[count] += 1
for i in range(1, 10):
    num[i] //= i
print(((H - 2) * (W - 2) - sum(num)))
for i in range(1, 10):
    print((num[i]))
# Original solution
from collections import defaultdict

H, W, N = list(map(int,input().split()))
  
ans =[(H-2)*(W-2)]+[0]*9
blacks = defaultdict(int)
for i in range(N):
  a, b = list(map(int,input().split()))
  for dx in [-1,0,1]:
    for dy in [-1,0,1]:
      if 2 <= a+dx <H and 2 <= b+dy <W:
        ans[blacks[(a+dx,b+dy)]]-=1
        ans[blacks[(a+dx,b+dy)]+1]+=1
      blacks[(a+dx,b+dy)]+=1
        
for i in range(10): print((ans[i]))


# Optimized solution
h,w,n=list(map(int,input().split()))
dic={}
dx=[-2,-1,0]
dy=[-2,-1,0]
ans=[0]*10
for _ in range(n):
  a,b=list(map(int,input().split()))
  for x in dx:
    for y in dy:
      if 1<=a+y and a+y+2<=h and 1<=b+x and b+x+2<=w:
        if (a+y,b+x) not in dic:
          dic[(a+y,b+x)]=1
        else:
          dic[(a+y,b+x)]+=1
ans[0]=(h-2)*(w-2)-len(dic)
for v in list(dic.values()):
  ans[v]+=1
for i in range(10):
  print((ans[i]))
# Original solution
H, W, N = map(int, input().split())
ab = set(tuple(map(int, input().split())) for i in range(N))

dxy = {0:[0, 1, 2], 1:[-1, 0, 1], 2:[-2, -1, 0]}
num_all = (H - 2) * (W - 2)
num = [0] * 10
for a, b in ab:
  for i in range(3):
    Da = dxy[i]
    for j in range(3):
      n = 0
      flag = False
      Db = dxy[j]
      for da in Da:
        aa = a + da
        for db in Db:
          bb = b + db
          if aa < 1 or H < aa or bb < 1 or W < bb:
            flag = True
            break
          if (aa, bb) in ab:
            n += 1
        if flag:
          break
      if flag:
        continue
      num[n] += 1

for i in range(2, 10):
  num[i] //= i

num[0] = num_all - sum(num[1:])
print(*num, sep='\n')


# Optimized solution
import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
ab = set(tuple(map(int, input().split())) for i in range(N))

dxy = {0:[0, 1, 2], 1:[-1, 0, 1], 2:[-2, -1, 0]}
num_all = (H - 2) * (W - 2)
num = [0] * 10
for a, b in ab:
  for i in range(3):
    Da = dxy[i]
    for j in range(3):
      n = 0
      flag = False
      Db = dxy[j]
      for da in Da:
        aa = a + da
        for db in Db:
          bb = b + db
          if aa < 1 or H < aa or bb < 1 or W < bb:
            flag = True
            break
          if (aa, bb) in ab:
            n += 1
        if flag:
          break
      if flag:
        continue
      num[n] += 1

for i in range(2, 10):
  num[i] //= i

num[0] = num_all - sum(num[1:])
print(*num, sep='\n')
# Original solution
from collections import Counter
h,w,n = list(map(int,input().split()))
need = []
for i in range(n):
    a,b = list(map(int,input().split()))
    for x in range(-2,1):
        for y in range(-2,1):
            s = a + x
            t = b + y
            if 1 <= s <= h-2 and 1 <= t <= w-2:
                need.append(s*10**10 + t)

data = Counter(need).most_common()
ans = [0 for i in range(10)]
for x,y in data:
    ans[y] += 1

print(((h-2)*(w-2)-sum(ans)))
for i in ans[1:]:
    print(i)


# Optimized solution
from collections import Counter
h,w,n = list(map(int,input().split()))
need = []
append = need.append
for i in range(n):
    a,b = list(map(int,input().split()))
    for x in range(-2,1):
        for y in range(-2,1):
            s = a + x
            t = b + y
            if 1 <= s <= h-2 and 1 <= t <= w-2:
                append(s*10**10 + t)

data = Counter(need).most_common()
ans = [0 for i in range(10)]
for x,y in data:
    ans[y] += 1

print(((h-2)*(w-2)-sum(ans)))
for i in ans[1:]:
    print(i)
# Original solution
def solve(h,w,n,black_list):
  idx_list = []
  for idx, (a,b) in enumerate(black_list):
    left = max(0, b-3)
    top = max(0, a-3)
    for row in range(top, a):
      if row+2 >= h:
        continue
      for col in range(left, b):
        if col+2 >= w:
          continue
        idx_list.append(row*h+col)

  set_count = set(idx_list)
  ans = [0]*len(set_count)
  for idx,i in enumerate(set_count):
    ans[idx] = idx_list.count(i)

  ret = [(h-2)*(w-2)-len(set_count)]
  for i in range(1, 10):
    ret.append(ans.count(i))
  return ret

if __name__ == "__main__":
  h,w,n = list(map(int,input().split()))
  black_list = [tuple(map(int,input().split())) for _ in range(n)]
  ret = solve(h,w,n,black_list)
  for i in ret:
    print(i)


# Optimized solution
def solve(h,w,n,black_list):
  if len(black_list) == 0:
    return [(h-2)*(w-2)]+[0]*9
  idx_list = []
  for idx, (a,b) in enumerate(black_list):
    left = max(0, b-3)
    top = max(0, a-3)
    for row in range(top, a):
      if row+2 >= h:
        continue
      for col in range(left, b):
        if col+2 >= w:
          continue
        idx_list.append(row*w+col)

  set_count = set(idx_list)
  idx_list = sorted(idx_list)

  ans = [0]*9
  now = idx_list[0]
  count = 0
  for item in idx_list:
    if item == now:
      count += 1
    else:
      now = item
      if count == 10:
        print(item)
      ans[count-1] += 1
      count = 1
  ans[count-1] += 1
  return [(h-2)*(w-2)-len(set_count)]+ans


if __name__ == "__main__":
  h,w,n = list(map(int,input().split()))
  black_list = [tuple(map(int,input().split())) for _ in range(n)]
  ret = solve(h,w,n,black_list)
  for i in ret:
    print(i)
# Original solution
n = int(input())
s = input()
uppercase = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
t = ''
for ch in s:
    ind = uppercase.index(ch)
    ind = (ind + n) % 26
    t += uppercase[ind]
print(t)

# Optimized solution
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n= int(input())
x = input()
a = ord('A')
print(''.join([s[(ord(c) - a + n) % 26] for c in x]))
# Original solution
# 2019-11-24 20:59:47(JST)
import sys
from string import ascii_uppercase as alphabet

alpha_num = dict((alpha, num) for num, alpha in enumerate(alphabet, 0))

def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    t = ''
    for char in s:
        t += alphabet[(alpha_num[char] + n) % 26]
    
    print(t)

if __name__ == '__main__':
    main()


# Optimized solution
# 2019-11-24 20:59:47(JST)
import sys
from string import ascii_uppercase as alphabet

# alpha_num = dict((alpha, num) for num, alpha in enumerate(alphabet, 0))
alpha_ind = dict((alphabet[i], i) for i in range(26))

def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    t = ''
    for char in s:
        t += alphabet[(alpha_ind[char] + n) % 26]
    
    print(t)

if __name__ == '__main__':
    main()
# Original solution
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

word = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(readline())
S = readline().decode('utf8').rstrip()

ans = [None] * len(S)
for i in range(len(S)):
    ans[i] = word[(word.index(S[i]) + N) % len(word)]

ans=''.join(ans)
print(ans)


# Optimized solution
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# word = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(readline())
S = [int(x)-ord('A') for x in read().rstrip()]
S=[(x+N)%26 for x in S]

ans = ''.join(chr(x+ord('A')) for x in S)

print(ans)
# Original solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    al = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    ans = []
    for i in range(len(s)):
        for j in range(len(al)):
            if s[i] == al[j]:
                ans.append(al[(j+n) % 26])
                break
    print(("".join(ans)))


if __name__ == '__main__':
    solve()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    ls = {i - 65: chr(i) for i in range(65, 91)}
    ans = []
    for i in range(len(s)):
        ans.append(ls[(ord(s[i]) - 65 + n) % 26])
    print(("".join(ans)))
    

if __name__ == '__main__':
    solve()
# Original solution
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
s = input()
for i in s:
  k = l.index(i)+n
  print(l[k%26], end="")
print("")


# Optimized solution
n = int(input())
s = input()
l = [chr(ord("A")+i) for i in range(26)]*2
for i in s:
  print(l[l.index(i)+n], end="")
print()
# Original solution
n = int(eval(input()))
a = []
for i in range(n):
    a.append(int(eval(input())))

b = a[1] - a[0]
for i in range(n):
    for j in range(i+1 , n):
        if b < a[j] - a[i]:
            b = a[j] - a[i]

print(b)




# Optimized solution
n = int(eval(input()))
a = []
for i in range(n):
    a.append(int(eval(input())))

mini = a[0]
b = -10000000000
del a[0]
for i in a:
    if b < i - mini:
        b = i - mini
    if mini > i:
        mini = i

print(b)
# Original solution
n = eval(input())
R = [eval(input())] 
Rmin = 0
maxdif = -999999999
for i in range(n-1):
    Rt = eval(input())
    for j in range(Rmin, len(R)):
        if (Rt - R[j]) > maxdif:
            maxdif = Rt - R[j]
    if Rt < Rmin:
        Rmin = i + 1
    R.append(Rt)

print(maxdif)

# Optimized solution
n = eval(input())
R = [eval(input())] 
Rmin = 0
maxdif = -999999999
for i in range(n-1):
    Rt = eval(input())
    for j in range(Rmin, len(R)):
        if (Rt - R[j]) > maxdif:
            maxdif = Rt - R[j]
    if Rt < R[Rmin]:
        Rmin = i + 1
    R.append(Rt)

print(maxdif)
# Original solution
n = eval(input())
R = [eval(input())] 
Rmin = 0
maxdif = -999999999
for i in range(n-1):
    Rt = eval(input())
    for j in range(Rmin, len(R)):
        if (Rt - R[j]) > maxdif:
            maxdif = Rt - R[j]
    if Rt < R[Rmin]:
        Rmin = i + 1
    R.append(Rt)

print(maxdif)

# Optimized solution
n = eval(input())
R = [eval(input()) for i in range(n)]

Rmin = n
maxdif = R[1] - R[0]

while Rmin > 0:
    tRmin = R.index(min(R[0:Rmin]))
    Rmax = R.index(max(R[tRmin:Rmin]))
    if tRmin == Rmax:
        if tRmin == n-1:
            tRmin-=1
        elif tRmin < n-1:
            Rmax = tRmin + 1
    Rmin = tRmin
    if (R[Rmax] - R[Rmin]) > maxdif:
        maxdif = R[Rmax] - R[Rmin]

print(maxdif)
# Original solution
#coding:utf-8

n = int(eval(input()))

pri_list = [int(eval(input())) for i in range(n)]
gap_list = []
for i in range(n-1):
    gap = max(pri_list[i+1:]) - pri_list[i]
    gap_list.append(gap)
max_ben = max(gap_list)

print(max_ben)



# Optimized solution
#coding:utf-8

n = int(eval(input()))
minv = int(eval(input()))
maxv = -10000000000
for i in range(n-1):
    price = int(eval(input()))
    maxv = max([maxv, price - minv])
    minv = min([minv, price])

print(maxv)
# Original solution
n = int(input())
R = list()
max = -10000000000

for i in range(n):
    R.append(int(input()))
    for j in range(i):
        if max < R[i] - R[j]:
            max = R[i] - R[j]
            
print(max)

# Optimized solution
n = int(input())
R = list()
max = -10000000000
min =  10000000000

for i in range(n):
    R.append(int(input()))

    if max < R[i] - min:
        max = R[i] - min

    if min > R[i]:
        min = R[i]
print(max)
# Original solution


n=int(eval(input()))

list=[int(eval(input())) for i in range(n)]

max=list[1]-list[0]


for i in range(n-1,-1,-1):
	for j in range(i):
		x=list[i]-list[j]
		if x>max:
			max=x

		
print(max)



# Optimized solution

n=int(eval(input()))
a=[int(eval(input())) for i in range(n)]
min1=a[0]
max1=-float('inf')
for i in range(1, n):
    max1=max(a[i]-min1,max1)
    min1=min(a[i],min1)
print(max1)
# Original solution
i = 1
n = int(eval(input()))
maxR = -10**9
minR = int(eval(input()))
while i < n:
    R = int(eval(input()))
    maxR = max(maxR, R-minR)
    minR = min(minR, R)
    i += 1
print(maxR)

# Optimized solution
a, b = -1e9, 1e10
for n in range(int(eval(input()))):
    c = int(eval(input()))
    a, b = max(a, c - b), min(b, c)
print(a)
# Original solution
a, b = -1e9, 1e10
for n in range(int(eval(input()))):
    c = int(eval(input()))
    a, b = max(a, c - b), min(b, c)
print(a)

# Optimized solution
a = -1e9
b = 2e9
for n in range(int(eval(input()))):
    r = int(eval(input()))
    a = max(a, r - b)
    b = min(b, r)
print(a)