Problem:


Score : 200 points

Problem Statement

You are given an integer sequence A of length N.
Find the maximum absolute difference of two elements (with different indices) in A.

Constraints

2 \leq N \leq 100

1 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum absolute difference of two elements (with different indices) in A.

Sample Input 1

4
1 4 6 3

Sample Output 1

5

The maximum absolute difference of two elements is A_3-A_1=6-1=5.

Sample Input 2

2
1000000000 1

Sample Output 2

999999999

Sample Input 3

5
1 1 1 1 1

Sample Output 3

0



Sample input:
4
1 4 6 3


Sample output:
5

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
ans = []

for i in range(n):
  for j in range(i,n):
    ans.append(abs(l[i]-l[j]))
print(max(ans))

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))
print(a[-1]-a[0])

Submission status: Accepted

Solution code:
input()
a = sorted(list(map(int, input().split())))
print(a[-1]-a[0])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
print(max(A)-min(A))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split(" ")))

min_v=l[0]
max_v=l[0]

for i in range(n):
  if min_v > l[i]:
    min_v=l[i]
  if max_v < l[i]:
    max_v=l[i]

print(max_v-min_v)

Submission status: Accepted

Solution code:
N =input()
A = list(map(int,input().split()))
print(max(A)-min(A))

Submission status: Accepted

Solution code:
N = int (input ())
A = [int(x) for x in input ().split ()]
Ma = max (A)
Mi = min (A)
print (Ma - Mi)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

max_dif = 0
dif = 0

for i in range(0, N):
    for j in range(i+1, N):
        dif = abs(A[i]-A[j])
        if max_dif < dif:
            max_dif = dif

print("{}".format(max_dif))

Submission status: Accepted

Solution code:
n =int(input())
A = list(map(int, input().split()))
print(max(A)-min(A))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans = max(ans, abs(a[i] - a[j]))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
print(max(a) - min(a))

Submission status: Accepted

Solution code:
n=int(input())
*a,=map(int,input().split())
print(max(a)-min(a))

Submission status: Accepted

Solution code:
n = int(input())
array = list(map(int, input().split(' ')))
ans = max(array) - min(array)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
l = list(map(int, input().split()))
n_min = min(l)
n_max = max(l)
print(abs(n_max-n_min))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int, input().split()))

l.sort()

ans = l[n-1]-l[0]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
li = []
for i in range(n-1):
    for j in range(i+1,n):
        li += [abs(a[i]-a[j])]
print(max(li))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = a[-1] - a[0]
print(res)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())))
print(l[-1] - l[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
print(a[-1] - a[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

a.sort()

print(abs(a[-1] - a[0]))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    for j in range(N):
        if i>j :
            B.append(abs(A[i]-A[j]))
print(max(B))

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int,input().split(' ')))

max = 0
min = 1000000000

for i in nums:
    if i>max:
        max = i
    if i<min:
        min = i
    
print(max-min)

Submission status: Accepted

Solution code:
a=int(input())
b=[int(i) for i in input().split()]
mi=min(b)
ma=max(b)
print(ma-mi)

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int,input().split(' ')))

max = 0

for i in nums:
    for j in nums:
        if abs(i-j) > max:
            max = abs(i-j)
        
print(max)

Submission status: Accepted

Solution code:
n = int(input())
A = sorted(map(int, input().split()))
print(A[-1] - A[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = []
for i in range(n-1):
  for j in range(i+1, n):
    ans.append(abs(a[i]-a[j]))
    
#print(ans)
print(max(ans))

Submission status: Accepted

Solution code:
n = int(input())
A = sorted(list(map(int,input().split())))
print(A[n-1] - A[0])

Submission status: Accepted

Solution code:
def sa(x,j):
    c=[]
    for i in range(1,len(x)):
        c.append(abs(int(x[j])-int(x[i])))
    return max(c)

N=int(input())
A=list(map(str,input().split()))
ans=0
for j in range(N):
    y=sa(A,j)
    if y>ans:
        ans=y

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans = max(ans,abs(a[i]-a[j]))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

Submission status: Accepted

Solution code:
n = input()
a = list(map(int, input().split()))
a.sort()
print(a[-1] - a[0])

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
A.sort()
print(abs(A[0]-A[-1]))

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))

print(max(x)-min(x))

Submission status: Accepted

Solution code:
#
# abc102 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
1 4 6 3"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
1000000000 1"""
        output = """999999999"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
1 1 1 1 1"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    print(max(A)-min(A))


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))

x.sort()

answer = x[-1] - x[0]

print(answer)

Submission status: Accepted

Solution code:
N = int(input())
ls = list(map(int,input().split()))
print(max(ls)-min(ls))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
print(max(A)-min(A))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(1,N):
    for j in range(i):
        if ans <= abs(A[i]-A[j]):
            ans = abs(A[i]-A[j])

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
print(a[-1]-a[0])

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
  for j in range(i+1,N):
    ans=max(abs(A[i]-A[j]),ans)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))

maxa = 0
mina = 10**9

for a in A:
    if maxa < a:
        maxa = a
    if mina > a:
        mina = a

print(maxa-mina)

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	n = int(input())
	A = list(map(int,input().split()))

	print(abs(max(A) - min(A)))

Submission status: Accepted

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	
	print(max(A) - min(A))


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    print(max(A) - min(A))

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = sorted(rl())
print(li[-1] - li[0])

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
print(abs(max(L)-min(L)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a1 = set(a)
a2 = list(a1)
ans = 0
for i in range(len(a2)):
  for j in range(len(a2)):
    ans = max(ans,abs(a2[i] - a2[j]))
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

ans = max(a) - min(a)

print(ans)

Submission status: Accepted

Solution code:
n, *aaa = map(int, open(0).read().split())
print(max(aaa) - min(aaa))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(lambda a: int(a), input().split(" ")))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))

print(max(A)-min(A))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
    
al = list(map(int, input().split()))

ala = list(map(lambda x: abs(x),al))

ma =max(ala)
mi =min(ala)

print(ma-mi)

Submission status: Accepted

Solution code:
n=int(input());a=list(map(int,input().split()));d=[]
for i in range(n):
  for j in range(i+1,n):
    d.append(abs(a[i]-a[j]))
print(max(d))

Submission status: Accepted

Solution code:
n = input()
a = input().split()
list = []
for hoge in a:
  list.append(int(hoge))

x = max(list)
y = min(list)
print(x - y)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    print(max(A)-min(A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
_ = input()
A = list(map(int, input().split()))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    l = list(map(int, input().split()))
    l.sort()
    print(l[N-1]-l[0])
main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
mn=A[0]
mx=A[0]
for i in range(1,N):
    if A[i]<mn:
        mn=A[i]
    elif A[i]>mx:
        mx=A[i]
print(mx-mn)

Submission status: Accepted

Solution code:
n = int(input())

a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
ar =[int(i) for i in input().strip().split(" ")]
print(max(ar) - min(ar))

Submission status: Accepted

Solution code:
import itertools

X,*list1=open(0).read().split()

X=int(X)

list1=[int(i) for i in list1]

#print(list1)

list2=list(itertools.combinations(list1,2))

#print(list2)

aaa=[]

for i in list2:
    if i[0]>i[1]:
        aaa.append(i[0]-i[1])
    else:
        aaa.append(i[1]-i[0])

#print(aaa)

print(max(aaa))

Submission status: Accepted

Solution code:
n = int(input())
ar = list(map(int, input().split()))
print(abs(max(ar) - min(ar)))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]!=a[j]:
            ans=max(ans,abs(a[j]-a[i]))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

print(max(A) - min(A))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
maximum = max(a)
minimum = min(a)
print(maximum - minimum)

Submission status: Accepted

Solution code:
N=int(input())
A=tuple(map(int,input().split()))

print(max(A)-min(A))

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
A = [int(i) for i in input().split()]
a = list(combinations(A,2))
l =[]
for i in range(len(a)):
  l.append(abs(a[i][0] - a[i][1]))

print(max(l))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))

min_a=float("inf")
max_a=0
for aa in a:
  max_a=max(max_a,aa)
  min_a=min(min_a,aa)
print(max_a-min_a)

Submission status: Accepted

Solution code:
n = int(input())
a = [abs(i) for i in list(map(int, input().split()))]
a.sort()
print(a[-1] - a[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(len(a)):
    for j in range(i, len(a)):
        tmp = abs(a[i] - a[j])
        if tmp >= ans:
            ans = tmp
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(x) for x in input().split()]

min_value = -10000000
for i in range(n):
  for j in range(i+1, n):
    min_value = max(min_value, abs(l[i] - l[j]))
print(min_value)

Submission status: Accepted

Solution code:
s = input()
n = int(s)

arrays = []

max_num = 0

v = input().split()
for i in range(n):
    arrays.append(int(v[i]))

for i in range(len(arrays)):
    max_num = max(max_num, arrays[i])

min_num = max_num

for i in range(len(arrays)):
    min_num = min(min_num,arrays[i])

answer = max_num - min_num

print(answer)

Submission status: Accepted

Solution code:
n=input()
a=list(map(int,input().split()))
print(max(a)-min(a))

Submission status: Accepted

Solution code:
n = int(input())
data = list(map(int, input().split()))
print(max(data) - min(data))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
min=A[0]
max=A[0]
for i in range(N):
    if min>A[i]:
        min=A[i]
    if max<A[i]:
        max=A[i]

print(max-min)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = []
for i in range(n):
  for j in range(i+1,n):
    if i == n and j == n:
      pass
    else:
      x.append(abs(a[i]-a[j]))
print(max(x))

Submission status: Accepted

Solution code:
n = int(input())
numList = input().split()
minNum = numList[0]
maxNum = numList[n-1]

for i in range(len(numList)):
    if int(minNum) > int(numList[i]):
        minNum = numList[i]
    elif int(maxNum) < int(numList[i]):
        maxNum = numList[i]

print(int(maxNum) - int(minNum))

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()
print(max(A)-min(A))

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n=int(input())
num=list(map(int, input().split()))

print(max(num)-min(num))

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))

mx_a = 1
mn_a = 10**9
for i in range(N):
    if a[i] > mx_a:
        mx_a = a[i]
    if a[i] < mn_a:
        mn_a = a[i]
print(mx_a-mn_a)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        ans=max(ans,abs(a[i]-a[j]))
print(ans)

Submission status: Accepted

Solution code:
N =int(input())
a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
# abc102_b.py
# https://atcoder.jp/contests/abc102/tasks/abc102_b

# B - Maximum Difference /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 長さ Nの整数列 A が与えられます。 A の（添字の）異なる 2要素の差の絶対値の最大値を求めてください。

# 制約
#     2≤N≤100
#     1≤Ai≤109
#     入力はすべて整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# A1 A2 ... AN

# 出力
# Aの（添字の）異なる 2要素の差の絶対値の最大値を出力せよ。

# 入力例 1
# 4
# 1 4 6 3

# 出力例 1
# 5

# A3−A1=6−1=5が、異なる 2要素の差の最大値です。

# 入力例 2
# 2
# 1000000000 1

# 出力例 2
# 999999999

# 入力例 3
# 5
# 1 1 1 1 1

# 出力例 3
# 0


def calculation(lines):
    N = int(lines[0])
    values = [value for value in map(int, lines[1].split(' '))]
    max_diff = 0
    for i in range(len(values)):
        for j in range(len(values)):
            diff = abs(values[i] - values[j])
            if max_diff < diff:
                max_diff = diff
    return [max_diff]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4', '1 4 6 3']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['2', '1000000000 1']
        lines_export = [999999999]
    if pattern == 3:
        lines_input = ['5', '1 1 1 1 1']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = sorted(int(X) for X in input().split())
print(A[-1]-A[0])

Submission status: Accepted

Solution code:
#-------------
N = int(input())
A =list(map(int, input().split()))
#-------------
A.sort()
min = A[0]
max = A[-1]
X = max-min

print(X)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

print(abs(max(A) - min(A)))

Submission status: Accepted

Solution code:
n = int(input())
aa = tuple(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans = max(ans, abs(aa[i] - aa[j]))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
an = list(map(int, input().split()))

print(abs(max(an)-min(an)))

Submission status: Accepted

Solution code:
N=int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans = max(ans,abs(A[i]-A[j]))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
List = list(map(int, input().split()))
mid = 0
res = 0
for i in range(N):
  for j in range(i+1,N):
    mid = abs(List[i]-List[j])
    res = max(res,mid)
print(res)

Submission status: Accepted

Solution code:
N = int(input())
MM = input().split()
list1 =[]
for i in MM:
  a = int(i)
  list1.append(a)
list1.sort()
print(list1[-1] - list1[0])

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	n = int(input())
	A = list(map(int,input().split()))

	print(max(A) - min(A))

Submission status: Accepted

Solution code:
input()
a=sorted(list(map(int,input().split())))
print(abs(a[0]-a[-1]))

Submission status: Accepted

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[-1]-A[0])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(i+1, N):
        ans = max(ans, abs(A[i] - A[j]))
        
print(ans)

Submission status: Accepted

Solution code:
n = raw_input()
ais = map(int, raw_input().split())
print max(ais) - min(ais)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
lists = list(map(int, input().split()))
 
lists.sort()
print(lists[-1] - lists[0])

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
lists = list(map(int, input().split()))

arr = np.array(lists)
maximum = arr.max()
minimum = arr.min()
print(maximum - minimum)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
print(max(a)-min(a))

Submission status: Accepted

Solution code:
import itertools

n = int(input())
a_l = list(map(int, input().split()))
index_l = [i for i in range(len(a_l))]

# print(a_l)
# print(index_l)

max_ans = 0
for v in itertools.combinations(index_l, 2):
#   print(v[0])
#   print(v[1])
    ans = abs(a_l[v[0]] - a_l[v[1]])
    # print(ans)
    max_ans = max(max_ans, ans)
    
print(max_ans)

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a=sorted(map(int,input().split()))
    print(a[n-1]-a[0])
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
numlist = list(map(int,input().split()))
print(max(numlist) - min(numlist))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans = max(ans, abs(A[i]-A[j]))

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
li=list(map(int,input().split()))
print(max(li)-min(li))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
print(abs(max(A)-min(A)))

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    max_num = 0
    for i in range(n-1):
        for j in range(i+1,n):
            max_num = max(max_num, abs(num_list[i]-num_list[j]))

    print(max_num)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(input().split())
a.sort(key=int)
print(int(a[-1]) - int(a[0]))

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))

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

Submission status: Accepted

Solution code:

N = int(input())
A = list(map(int,input().split()))

out=0
for i in range(N-1):
    for j in range(i+1,N):
        out=max(out, abs(A[j]-A[i]))

print(out)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
print(abs(A[0]-A[-1]))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))
mmax = max(a)
mmin = min(a)
print(int(mmax - mmin))

Submission status: Accepted

Solution code:
N = int(input())
number = list(map(int,input().split()))
number.sort(reverse=True)
print(number[0]-number[-1])

Submission status: Accepted

Solution code:
N = int(input())
A = sorted(list(map(int,input().split())))

print(A[-1]-A[0])

Submission status: Accepted

Solution code:
N = int(input())

l = sorted(list(map(int,input().split())))
print(l[N-1]-l[0])

Submission status: Accepted

Solution code:
import math
def main():
  n = int(input())
  a=list(map(int,input().split()))
  max=a[0]
  min=a[0]
  
  for i in range(1,n):
    if a[i]>max:
      max=a[i]
    if a[i] < min:
      min=a[i]
  print(max-min)
main()

Submission status: Accepted

Solution code:
n = input()
a_lst = list(map(int, input().split(" ")))

a_lst.sort()

print(abs(a_lst[0] - a_lst[-1]))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
print(A[-1]-A[0])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split(" ")))

print(abs(max(A) - min(A)))

Submission status: Accepted

Solution code:
N = int(input())
numbers = list(map(int, input().split()))

result = 0

for a in numbers:
  for b in numbers:
    if abs(a-b)> result:
      result = abs(a-b)
    
print(result)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n=int(input())
a=sorted(list(map(int,input().split())))
print(a[-1]-a[0])

Submission status: Accepted

Solution code:
n=int(input())
a_list=[int(i) for i in input().split()]
a_list.sort()
print(a_list[-1]-a_list[0])

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    print(max(A) - min(A))


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
print(a[-1]-a[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n,1):
    ans=max(ans,abs(a[i]-a[j]))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
maxa=max(A)
mina=min(A)
print(maxa-mina)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

print(max(A)-min(A))

Submission status: Accepted

Solution code:
import sys
N = int(input())
array_A = list(map(int,input().split()))

if not (2 <= N <= 100):
    sys.exit()
for I in range(len(array_A)):
    if not (1 <= array_A[I] <= 10 ** 9):
        sys.exit()

print(max(array_A) - min(array_A))

Submission status: Accepted

Solution code:
n=int(input())
mylist=list(map(int,input().split()))
print(max(mylist)-min(mylist))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
print(max(a)-min(a))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = sorted(list(map(int,input().split())))

print(a[len(a) - 1] - a[0])

Submission status: Accepted

Solution code:
# B - Maximum Difference

N = int(input())
A = list(int(a) for a in input().split())

print(abs(max(A) - min(A)))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
print(max(A)-min(A))

Submission status: Accepted

Solution code:
N=int(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)

Submission status: Accepted

Solution code:
n = int(input())
s = list(map(int,input().split()))
s.sort()
print(abs(s[0] - s[-1]))

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
print(a[n - 1] - a[0])

Submission status: Accepted

Solution code:
n = int(input())
A = sorted(list(map(int, input().split())))
print(A[-1] - A[0])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))

A.sort()

print(A[len(A)-1]- A[0])

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split());print(max(a)-min(a))

Submission status: Accepted

Solution code:
n=input()
a=list(map(int, input().split()))
print(max(a)-min(a))

Submission status: Accepted

Solution code:
n=int(input())
a_list=[int(i) for i in input().split()]


print(max(a_list)-min(a_list))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))

if len(set(l)) == 1:
  print(0)
else:
  print(max(l) - min(l))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = -1
for i in range(N-1):
    for j in range(i+1, N):
        sub = abs(A[j]-A[i])
        ans = max(ans, sub)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
print(max(A)-min(A))

Submission status: Accepted

Solution code:
n=int(input())
A = list(map(int,input().split()))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
n = int(input())
an = [int(a) for a in input().split()]

print(abs(max(an)-min(an)))

Submission status: Accepted

Solution code:
n = int(input())
a_list = [int(i) for i in input().split()]
print(max(a_list) - min(a_list))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
d = 0

for i in range(n) :
    for j in range(n):
        x = a[i]-a[j]
        while d < x:
            d = x

print (d)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

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