CodeEff/ECCO huggingface dataset:
# Original solution
if __name__ == "__main__":
    N, M = list(map(int, (input().split(' '))))
    ura = 0
    if N == 1 and M != 1:
        arr = [0 for i in range(N)]
        ura = M - 2
    elif N != 1 and M == 1:
        arr = [0 for i in range(M)]
        ura = N - 2
    elif N == 1 and M == 1:
        ura = 1
    else:
        arr = [[0 for i in range(M)] for j in range(N)]
        for i in range(N):
            for j in range(M):
                for buf_i in range(-1, 2):
                    for buf_j in range(-1, 2):
                        if i-buf_i < 0 or i+buf_i >= N or j-buf_j < 0 or j+buf_j >= M:
                            continue
                        if arr[i+buf_i][j+buf_j] == 0:
                            arr[i+buf_i][j+buf_j] = 1
                        else:
                            arr[i+buf_i][j+buf_j] = 0
        for i in range(N):
            for j in range(M):
                if arr[i][j] == 1:
                    ura += 1
    print(ura)

# Optimized solution
if __name__ == "__main__":
    N, M = list(map(int, (input().split(' '))))
    ura = 0
    if N == 1 and M != 1:
        arr = [0 for i in range(N)]
        ura = M - 2
    elif N != 1 and M == 1:
        arr = [0 for i in range(M)]
        ura = N - 2
    elif N == 1 and M == 1:
        ura = 1
    else:
#        arr = [[0 for i in range(M)] for j in range(N)]
#        for i in range(N):
#            for j in range(M):
#                for buf_i in range(-1, 2):
#                    for buf_j in range(-1, 2):
#                        if i-buf_i < 0 or i+buf_i >= N or j-buf_j < 0 or j+buf_j >= M:
#                            continue
#                        if arr[i+buf_i][j+buf_j] == 0:
#                            arr[i+buf_i][j+buf_j] = 1
#                        else:
#                            arr[i+buf_i][j+buf_j] = 0
#        for i in range(N):
#            for j in range(M):
#                if arr[i][j] == 1:
#                    ura += 1
        ura = N * M - (N * 2 + M * 2 - 4)
    print(ura)
# Original solution
(n, m) = list(map(int, input().split()))
s = []
s.append([0 for _ in range(m + 2)])
for _ in range(n):
    s.append([0] + [1 for _ in range(m)] + [0])
s.append([0 for _ in range(m + 2)])

sans = [[0 for _ in range(m + 2)] for _ in range(n + 2)]

for i in range(1, n + 1):
    for j in range(1, m + 1):
        sans[i][j] = (\
        s[i + 1][j + 1]+ \
        s[i + 1][j]+ \
        s[i + 1][j - 1]+ \
        s[i][j + 1]+ \
        s[i][j] + \
        s[i][j - 1]+ \
        s[i - 1][j + 1]+ \
        s[i - 1][j]+ \
        s[i - 1][j - 1]) % 2

sums = 0
for i in range(len(sans)):
    sums += sum(sans[i])
print(sums)

# Optimized solution
(n, m) = list(map(int, input().split()))
if n == 1:
    if m == 1:
        print((1))
    else:
        print((m - 2))
elif m == 1:
    print((n - 2))
else:
    print(((n-2)*(m-2)))
# Original solution
def check(i, j, n, m):
  cnt = 0
  for a in [- 1, 0, 1]:
    for b in [- 1, 0, 1]:
      if(0 <= i + a and i + a < n and 0 <= j + b and j + b < m):
        cnt += 1
  if(cnt % 2 == 0):
    return 0
  else:
    return 1

n, m = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(m):
    cnt += check(i, j, n, m)

print(cnt)


# Optimized solution
n, m = list(map(int, input().split()))
print((abs((m * n) - (2 * (m + n) - 4))))
# Original solution
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0
    for i in range(M):
        tmp = 1
        if M > i + 1:
            tmp += 1
        if N > 1:
            tmp += 1
        if N > 1 and M > i + 1:
            tmp += 1
        if N > 1 and i - 1 >= 0:
            tmp += 1
        if i > 0:
            tmp += 1

        ans += tmp % 2
        # print(tmp, ans)
    if N >= 2:
        ans = ans * 2
    return ans


res = calc(_N, _M)

if _N >= 3:
    res += calc(_M, _N - 2)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

# Optimized solution
_N, _M = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    def hashicco(n, m):
        tmp = 1
        if n > 1:
            tmp += 1
        if m > 1:
            tmp += 1
            if n > 1:
                tmp += 1
        res = tmp % 2
        if n > 1:
            res *= 2
        if n > 1:
            res *= 2
        return res

    # ans += hashicco(N, M)

    v = 0
    if M > 2 and N == 1:
        v += M - 2
    h = 0
    if N > 2 and M == 1:
        h += N - 2

    return hashicco(N,M)+v+h


res = calc(_N, _M)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)
# Original solution
N, M = list(map(int, input().split()))

count = 0
for x in range(N):
    for y in range(M):
        sur = 1
        if x-1 >= 0 and y -1 >= 0: sur +=1
        if y -1 >= 0:               sur +=1
        if x+1 < N and y -1 >= 0:  sur +=1
        if x-1 >= 0:                sur +=1
        if x+1 < N:                 sur +=1
        if x-1 >= 0 and y +1 < M:  sur +=1
        if y +1 < M:                sur +=1
        if x+1 < N and y +1 < M:   sur +=1
        if sur %2 == 1:
            count += 1
print(count)


# Optimized solution
N, M = list(map(int, input().split()))
print((abs(N-2)*abs(M-2)))
# Original solution
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----

delta = [(-1,-1) , (0,-1), (1,-1),
         (-1, 0) , (0, 0), (1, 0),
         (-1, 1) , (0, 1), (1, 1)]


ans=0
for y in range(N):
    for x in range(M):
        
        check_cnt=0
        for d in delta:
            check_x = x + d[0]
            check_y = y + d[1]
            
            if 0 <= check_x <= (M-1) and 0 <= check_y <= (N-1):
                check_cnt += 1
        
        if check_cnt % 2 == 1:
            ans += 1

print(ans)


# Optimized solution
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----

ans = abs(N-2) * abs(M-2)
print(ans)
# Original solution
# -*- coding: utf-8 -*-

# 入力を各変数に格納
n, m = list(map(int, input().split()))

cells = [[1 for i in range(n)] for j in range(m)]

# カードを裏返す関数
def turnCard(_y, _x):

    global cells

    if cells[_y][_x] == 0:
        cells[_y][_x] = 1
    elif cells[_y][_x] == 1:
        cells[_y][_x] = 0

# 各マスを周回して8方向に裏返し処理
for y in range(m):
    for x in range(n):

        # そのマスを裏返す
        turnCard(y, x)
        # 左端以外
        if x != 0:
            # 左隣を裏返す
            turnCard(y, x-1)
        # 右端以外
        if x != n-1:
            # 右隣を裏返す
            turnCard(y, x+1)
        # 最上段以外
        if y != 0:
            # ひとつ上を裏返す
            turnCard(y-1, x)
        # 最下段以外
        if y != m-1:
            # ひとつ下を裏返す
            turnCard(y+1, x)
        # 左端と最上段以外
        if x != 0 and y != 0:
            # 左斜め上を裏返す
            turnCard(y-1, x-1)
        # 右端と最上段以外
        if x != n-1 and y != 0:
            # 右斜め上を裏返す
            turnCard(y-1, x+1)
        # 左端と最下段以外
        if x != 0 and y != m-1:
            # 左斜め下を裏返す
            turnCard(y+1, x-1)
        # 右端と最下段以外
        if x != n-1 and y != m-1:
            # 右斜め下を裏返す
            turnCard(y+1, x+1)
        
# 各マスを周回して裏のマスで+1
ans = 0
for y in range(m):
    for x in range(n):
        if cells[y][x] == 0:
            ans += 1
print(ans)

# Optimized solution
# -*- coding: utf-8 -*-

# 入力を各変数に格納
n, m = list(map(int, input().split()))

ans = 0

# 行列ともに1
if n == 1 and m == 1:
    ans = 1
# 行が1
elif n == 1:
    ans = m - 2
# 列が1
elif m == 1:
    ans = n - 2
# 行列とも1ではない
else:
    ans = (n - 2) * (m - 2)

print(ans)
# Original solution
N, M = list(map(int, input().split()))
print((abs(N-2)*abs(M-2)))

# Optimized solution
N,M= list(map(int,input().split()))
print((abs((N-2)*(M-2))))
# Original solution
n,m=[int(i) for i in input().split()]
print((abs(n-2)*abs(m-2)))

# Optimized solution
n,m=[int(i) for i in input().split()]
if n==m==1:
    print((1))
elif min(n,m)==1:
    print((max(n,m)-2))
else:
    print(((n-2)*(m-2)))
# Original solution
N,M = list(map(int,input().split()))

if N ==1 and M == 1:
  print((1))
elif min(N,M) == 1 and max(N,M) >= 3:
  print((N*M-2))
elif N == 2 or M == 2:
  print((0))
else:
  print(((N-2)*(M-2)))

# Optimized solution
N,M = list(map(int,input().split()))

if N == 1 and M == 1:
  print((1))
elif min(N, M) == 1:
  print((max(N, M) - 2))
else:
  print(((N-2)*(M-2)))
# Original solution
N, M = sorted(map(int, input().split()))
print((abs((N - 2) * (M - 2))))


# Optimized solution
N, M = list(map(int, input().split()))
print((abs((N - 2) * (M - 2))))
# Original solution
N,M = list(map(int,input().split()))
if N == 1 and M == 1: print((1))
elif N == 1: print((M-2))
elif M == 1: print((N-2))
else: print(((M-2)*(N-2)))

# Optimized solution
N, M = list(map(int, input().split()))
if N == 1 and M == 1:
    print((1))
elif N == 1 and M != 1:
    print((M - 2))
elif M == 1 and N != 1:
    print((N - 2))
else:
    print(((N - 2) * (M - 2)))
# Original solution
n, m = list(map(int,input().split()))
if n == 1 and m == 1:
    ans = 1
elif n == 1:
    ans = m-2
elif m == 1:
    ans = n-2
else:
    ans = (n-2)*(m-2)
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))
if (n == 1) and (m == 1):
    ans = 1
elif (n == 1) or (m == 1):
    ans = max(n,m) -2
else:    
    ans = (n-2) * (m-2)
print(ans)
# Original solution
def solve():
  c = list(map(int, input().split(' ')))
  if c[0] >= 3 and c[1] >= 3:
    return (c[0] - 2) * (c[1] - 2)
  if c[0] == 1 or c[1] == 1:
    if c[0] == 1 and c[1] == 1:
      return 1
    else:
      return max(max(c) - 2, 0)
  return 0

print((solve()))

# Optimized solution
j = list(map(int, input().split()))
counter = 0
j.sort()

if (j[0] >= 3):
  print(((j[0] - 2) * (j[1] - 2)))
elif (j[0] == 2):
  print((0))
elif (j[0] == 1):
  if j[1] == 1:
    print((1))
  else:
    print((j[1] - 2))
# Original solution
n,m=list(map(int, input().split()))
f=[[1 for _ in range(m+2)] for _ in range(n+2)]

# 1:表，0:裏
# 裏返す:-1を加える

for i in range(1,n+1):
    for j in range(1,m+1):
        for k in range(i-1,i+2):
            for l in range(j-1,j+2):
                f[k][l]-=1
                if f[k][l]==-1:
                    f[k][l]=1

cnt=0
for i in range(1,n+1):
    for j in range(1,m+1):
        if f[i][j]==0:
            cnt+=1
print(cnt)


# Optimized solution
n, m = list(map(int, input().split()))

if n == 1 and m == 1:
    print((1))
elif n == 1:
    print((m-2))
elif m == 1:
    print((n-2))
else:
    print(((n-2)*(m-2)))
# Original solution
url = "https://atcoder.jp/contests/abc090/tasks/arc091_a"
import copy
def main():
    tate, yoko = list(map(int, input().split()))
    count = 0
    if tate == 1 and yoko == 1:
        print("1")
        exit()
    elif tate == 1:
        print((yoko - 2))
        exit()
    elif yoko == 1:
        print((tate - 2))
        exit()
    for t in range(1, tate + 1):
        if t == 1 or t == tate:
            count += 0
        else:
            count += yoko - 2
    print(count)




if __name__ == '__main__':
    main()




# Optimized solution
url = "https://atcoder.jp/contests/abc090/tasks/arc091_a"
import copy
def main():
    tate, yoko = list(map(int, input().split()))
    count = 0
    if tate == 1 and yoko == 1:
        print("1")
        exit()
    elif tate == 1:
        print((yoko - 2))
        exit()
    elif yoko == 1:
        print((tate - 2))
        exit()
    count += (yoko - 2) * (tate - 2)
    print(count)




if __name__ == '__main__':
    main()
# Original solution
S = input().split(" ")
N = int(S[0])
M = int(S[1])

def calculate(n,m):
    result = []
    for i in range(n):
        for j in range(m):
            count = 0
            if i - 1 >=0:
                count = count + 1

            if i + 1 <= n - 1:
                count = count + 1

            if j - 1 >= 0:
                count = count + 1

            if j + 1 <= m - 1:
                count = count + 1

            if (i -1 >= 0) and (j-1 >= 0):
                count = count + 1

            if (i - 1 >= 0) and (j + 1 <= m - 1):
                count = count + 1

            if (i + 1 <= n - 1) and (j - 1 >= 0):
                count = count + 1

            if (i + 1 <= n - 1) and (j + 1 <= m - 1):
                count = count + 1


            result.append((count+1) % 2)

    print((sum(result)))
calculate(N,M)

# Optimized solution
S = input().split(" ")
N = int(S[0])
M = int(S[1])

def calculate(n,m):

    if n == 1 and m == 1:
        return 1

    if n == 1:
        return m - 2

    if m == 1:
        return n - 2

    return (n - 2) * (m - 2)
result = calculate(N,M)
print(result)
# Original solution
N, M = list(map(int, input().split()))


def main():
    if N - 2 < 0 or M - 2 < 0:
        print((max(1, N - 2) * max(1, M - 2)))
    else:
        print(((N - 2) * (M - 2)))

    return


main()


# Optimized solution
def main():
    N, M = list(map(int, input().split()))

    if 1 < N:
        N -= 2

    if 1 < M:
        M -= 2

    print((N * M))

    return


main()
# Original solution
n,m = list(map(int, input().split()));print((abs((n*m)-(n*2)-(m-2)*2)))

# Optimized solution
n,m = list(map(int, input().split()))
print((abs((n-2)*(m-2))))
# Original solution
#!/usr/bin/env python3

from math import *
from itertools import *
from collections import *
from bisect import *


if __name__ == '__main__':
    n,m = list(map(int, input().split()))

    if n == 1:
        if m == 1:
            print((1))
        else:
            print((m-2))
    elif m == 1:
        print((n-2))
    else:
        center = n*m - 2*n - 2*m + 4
        print(center)



# Optimized solution
#!/usr/bin/env python

# Initially, all cards face up.
# Given that N,M >= 0.
# Let N <= M.
# Ultimately:
#   if N,M==1:      singular card will flip.
#   elif N==1:      interior cards will flip (interior to line).
#   else N,M > 1:   interior cards will flip (interior to area).

# Fetching input
N,M = list(map(int,input().split()))

# Ensuring N <= M
if N > M:
    M,N = N,M

# Requires N <= M:
def numflips(N,M):
    if N==0: return 0
    if N==1:
        if M==1: return 1
        return (M-2)
    return (N-2)*(M-2)

ans = numflips(N,M)
print(ans)
# Original solution
n, m = list(map(int, input().split()))
A = []
A.append([0 for _ in range(m+2)])
for _ in range(n):
    A.append([0] + [1 for _ in range(m)] + [0])
A.append([0 for _ in range(m+2)])

for i in range(1, n+1):
    for j in range(1, m+1):
        A[i][j-1] *= -1
        A[i][j] *= -1
        A[i][j+1] *= -1
        A[i+1][j-1] *= -1
        A[i+1][j] *= -1
        A[i+1][j+1] *= -1
        A[i-1][j-1] *= -1
        A[i-1][j] *= -1
        A[i-1][j+1] *= -1
        
import itertools
print((list(itertools.chain.from_iterable(A)).count(-1)))

# Optimized solution
n, m = list(map(int, input().split()))

import itertools
print((abs(m*n - ((n-1)*2 + (m-1)*2))))
# Original solution
n, m = list(map(int, input().split()))

field = []
for i in range(n + 2):
    row = [0 for j in range(m + 2)]
    field.append(row)
#print(field)

for i in range(1, n + 1):
    for j in range(1, m + 1):
        field[i][j] = 1
#print(field)

for i in range(1, n + 1):
    for j in range(1, m + 1):
        # 左上
        field[i - 1][j - 1] *= -1
        # 上
        field[i - 1][j] *= -1
        # 右上
        field[i - 1][j + 1] *= -1
        # 左
        field[i][j - 1] *= -1
        # 自分
        field[i][j] *= -1
        # 右
        field[i][j + 1] *= -1
        # 左下
        field[i + 1][j - 1] *= -1
        # 下
        field[i + 1][j] *= -1
        # 右下
        field[i + 1][j + 1] *= -1

count = 0
for i in range(1, n + 1):
    for j in range(1, m + 1):
        if field[i][j] == -1:
            count += 1

print(count)


# Optimized solution
n, m = list(map(int, input().split()))

x = n - 2
if x < 0:
    x = 0

y = m - 2
if y < 0:
    y = 0

if n == 1 and m == 1:
    print((1))
elif n == 1 and m > 1:
    print(y)
elif n > 1 and m == 1:
    print(x)
else:
    print((x * y))
# Original solution

def main():
    N,M =list(map( int,input().split()))
    arr = [[1 for i in range(N+2)] for j in range(M+3)]
    ans = 0
    
    for y in range(1,N+1):
        for x in range(1,M+1):
                arr[x][y] = 0 if arr[x][y] else 1 
                arr[x-1][y] = 0 if arr[x-1][y] else 1 
                arr[x][y-1] = 0 if arr[x][y-1] else 1 
                arr[x-1][y-1] = 0 if arr[x-1][y-1] else 1 
                arr[x+1][y] = 0 if arr[x+1][y] else 1 
                arr[x][y+1] = 0 if arr[x][y+1] else 1 
                arr[x+1][y+1] = 0 if arr[x+1][y+1] else 1
                arr[x+1][y-1] = 0 if arr[x+1][y-1] else 1
                arr[x-1][y+1] = 0 if arr[x-1][y+1] else 1
                
    
    for y in range(1,N+1):
        for x in range(1,M+1):
            if arr[x][y] == 0:
                ans = ans + 1

    print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
N,M = list(map(int,input().split()))
ans = (N-2)*(M-2)
if N == 1 and M == 1:
    ans = 1
elif M == 1:
    ans = abs(N - 2)
print((abs(ans)))
# Original solution
N,M = (int(X) for X in input().split())
if N==1 or M==1:
    if N==M:
        print((1))
    else:
        print((max(N,M)-2))
else:
    Four = 4
    Six  = 2*(N+M-4)
    Nine = N*M-(Four+Six)
    print(Nine)

# Optimized solution
N,M = (int(X) for X in input().split())
if N==1 or M==1:
    if N==M: print((1))
    else: print((max(N,M)-2))
else: print(((N-2)*(M-2)))
# Original solution
N , M = list(map(int,input().split()))
if N == 1 and M == 1:
    print("1")
elif N == 1:
    print((M - 2))
elif M == 1:
    print((N - 2))
else:
    print(((N - 2) * (M - 2)))

# Optimized solution
N, M = list(map(int, input().split()))
if N == M == 1:
    print("1")
elif N == 1:
    print((max(0, M - 2)))
elif M == 1:
    print((max(0, N - 2)))
else:
    print((max(N * M - (N - 1) * 2 - (M - 1) * 2, 0)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

a.sort()
print((a[-1] - a[0]))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
maximum = max(a)
minimum = min(a)
print((maximum - minimum))
# Original solution
# ABC102B - Maximum Difference
n = int(eval(input()))
lst = list(map(int, input().rstrip().split()))
max_dif = 0

for i in range(n):
    for j in range(n):
        max_dif = max(max_dif, abs(lst[i] - lst[j]))
    
print(max_dif)

# Optimized solution
# ABC102B - Maximum Difference
# Better ver.
n = int(eval(input()))
lst = sorted(list(map(int, input().rstrip().split())))
print((lst[-1] - lst[0]))
# Original solution
n = eval(input())
a = sorted(map(int,input().split()))
print((a[-1]-a[0]))


# Optimized solution
n=int(eval(input()))
A=list(map(int,input().split()))
print((max(A)-min(A)))
# Original solution
#!/usr/bin/env python3
N = int(eval(input()))
A = list(map(int, input().split(' ')))

A.sort()
print((abs(A[-1]- A[0])))

# Optimized solution
#!/usr/bin/env python3
N = int(eval(input()))
A = list(map(int, input().split(' ')))

min, max = A[0], A[0]
for i in range(N-1):
    if A[i+1] < min:
        min = A[i+1]
    elif A[i+1] > max:
        max = A[i+1]

print((max-min))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse=True)
print((a[0]-a[-1]))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
print((A[-1]-A[0]))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

mn = 10**9+1 # 数列Aの最小値
mx = 0       # 数列Aの最大値

for v in A:
  if v < mn:
    mn = v   # 最小値を更新
  if v > mx:
    mx = v   # 最大値を更新

print((mx-mn))


# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
print((max(A)-min(A)))
# Original solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
ans = -inf
for i in range(n):
    for j in range(n):
        ans = max(ans, abs(a[i]-a[j]))
print(ans)

# Optimized solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
print((max(a) - min(a)))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
print((abs(a[-1] - a[0])))

# Optimized solution
N = eval(input())
A = list(map(int, input().split()))
top = 0
bottom = 10 ** 9
for a in A:
    if a > top:
        top = a
    if a < bottom:
        bottom = a
print((abs(top - bottom)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n-1):
        temp=abs(a[i]-a[j])
        ans=max(ans,temp)
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
print((max(a)-min(a)))
# Original solution
# ABC 102: B – Maximum Difference
n = int(eval(input()))
a = [int(s) for s in input().split()]

print((abs(max(a) - min(a))))

# Optimized solution
# ABC 102: B – Maximum Difference
n = int(eval(input()))
a = [int(s) for s in input().split()]
a.sort()
print((a[-1] - a[0]))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
maxabs = 0

for i in range(n):
  for j in range(i+1,n):
    c = abs(a[i] - a[j])
    maxabs = max(maxabs,c)
    
print(maxabs)


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))

print((max(a)-min(a)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if abs(a[i]- a[j]) > ans:
            ans = abs(a[i]- a[j])
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mx = 0
for i in range(n):
  for j in range(i+1,n):
    if mx < abs(a[i] - a[j]):
      mx = abs(a[i] - a[j])
print(mx)
# Original solution
n = int(eval(input()))
ar = list(map(int, input().split()))
print((abs(max(ar) - min(ar))))

# Optimized solution
n = int(eval(input()))
ar =[int(i) for i in input().strip().split(" ")]
print((max(ar) - min(ar)))
# Original solution
N=int(eval(input()))
A=[int(x) for x in input().split()]
ans=0
for i in range(N):
    for j in range(N):
        ans=max(ans,abs(A[i]-A[j]))
print(ans)

# Optimized solution
N=int(eval(input()))
A=[int(x) for x in input().split()]
print((max(A)-min(A)))
# Original solution
count=eval(input())
list=input().rstrip().split(" ")
list_1=[int(s) for s in list]
list2= sorted(list_1)
sa=(list2[0]-list2[int(count)-1])
if sa<0:
  print((-1*sa))
else:
  print(sa)

# Optimized solution
count=eval(input())
list=input().rstrip().split(" ")
list_1=[int(s) for s in list]
list2= sorted(list_1)
sa=(max(list2)-min(list2))
if sa<0:
  print((-1*sa))
else:
  print(sa)
# Original solution
n = int(eval(input()))
maximum = 0
a = list(map(int,input().split()))
for i in range(n):
  for j in range(i+1,n):
    if abs(a[i]-a[j]) > maximum:
      maximum = abs(a[i]-a[j])
print(maximum)

# Optimized solution
a = int(eval(input()))
lis = list(map(int,input().split()))
print((max(lis)-min(lis)))
# Original solution
from itertools import*;n,*a=list(map(int,open(0).read().split()));print((max(abs(i[0]-i[1])for i in combinations(a,2))))

# Optimized solution
n,*a=list(map(int,open(0).read().split()));print((max(a)-min(a)))