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:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = max(A) - min(A)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int, input().split()))
ans = 0
for i in li:
    for j in li:
        if abs(i - j) > ans:
            ans = abs(i-j)

print(ans)

Submission status: Accepted

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

res = 0
for i in range(N):
    for j in range(i+1,N):
        diff = abs(A[i] - A[j])
        if diff > res:
            res = diff
print(res)

Submission status: Accepted

Solution code:
a = int(input())

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

print(max(b) - min(b))

Submission status: Accepted

Solution code:
n = int(input())
list=[int(s)for s in input().split()]
a = max(list)
b = min(list)
print(a-b)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

As = sorted(A)
ans = As[N-1] - As[0]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

A.sort()
ans = A[N-1] - A[0]
print(ans)

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())
aLst = list(map(int, input().split()))

aLst.sort()
tmpMin = aLst[0]
tmpMax = aLst[N - 1]
ans = tmpMax - tmpMin
print(ans)

Submission status: Accepted

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

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):
        dist = abs(a[j] - a[i])
        if dist > ans:
            ans = dist

print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ma = 0
    mi = 10000000000
    for i in a:
        ma = max(ma,i)
        mi = min(mi,i)
    print(ma-mi)

main()

Submission status: Accepted

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

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 = list(map(int, input().split()))
print(max(A) -min(A))

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    a = list(int(_) for _ in input().split())
    print(max(a)-min(a))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

N = SORO_INT()
A = list(MULT_INT_MAP())
x = max(A) - min(A)
print(x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    if n % 2:
        print(2 * n)
    else:
        print(n)
    return

#B
def B():
    n = II()
    a = LI()
    a.sort()
    print(a[n-1]-a[0])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

ans = -1
N = INT()
A = LIST()
C = list(combinations(A, 2))
for c in C:
    a, b = c
    if ans < abs(a - b):
        ans = max(ans, abs(a - b))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())

numsStr = input().split()
nums = []
for i in numsStr:
    nums.append(int(i))


ans = max(nums) - min(nums)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int,input().split()))
r = []
for x in range(N):
  for y in range(x+1, N):
    r.append(abs(As[x]-As[y]))
print(max(r))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(s) for s in 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 a:
    for j in a:
        ans = max(ans, abs(i - j))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
ls = list(map(int, input().split()))
res = -1

for i, j in combinations(ls, 2):
    res = max(res, abs(i-j))
print(res)

Submission status: Accepted

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

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()))

b = sorted(a)
c = abs(b[-1] - b[0])

print(c)

Submission status: Accepted

Solution code:
N = int(input())
lis = [int(i) for i in input().split()]

lis.sort()

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    al = list(map(int, input().split()))

    al.sort()

    print(al[n-1] - al[0])

Submission status: Accepted

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

print(max(l)-min(l))

Submission status: Accepted

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

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:
from itertools import combinations
n = int(input())
a = list(map(int, input().split()))
ans = 0

for i, j in combinations(a, 2):
    ans = max(ans, abs(i - j))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
items = input().split(" ")
nums = []
for i in range(a):
  nums.append(int(items[i]))
max_num = max(nums)
min_num = min(nums)
print(max_num - min_num)

Submission status: Accepted

Solution code:
#import math
n = int(input())
a=list(map(int,input().split()))
dif_max=0
for i in a:
    for j in a:
        dif=abs(i-j)
        if dif>=dif_max:
            dif_max = dif

print(dif_max)

Submission status: Accepted

Solution code:
N = int(input())
getList = input().split(' ')
getList = [int(n) for n in getList]
print(int(max(getList)) - int(min(getList)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(zz) for zz in input().split()]

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

Submission status: Accepted

Solution code:
n = int(input())
#h, w = map(int,input().split())
ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#ls = [input() for i in range(h)]
#n = input()

print(abs(max(ls)-min(ls)))

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())
a = list(map(int,input().split()))
print(abs(max(a) - min(a)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(max(alist)-min(alist))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        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=list(map(int, input().split()))
A.sort()
print(A[N-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())
x=list(map(int,input().split()))

x.sort()

res=abs(x[0]-x[n-1])

print(res)

Submission status: Accepted

Solution code:
# coding: UTF-8

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

print(max(As)- min(As))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
As = nl()

max_diff = 0
for i in range(N-1):
    for j in range(i+1, N):
        diff = abs(As[i] - As[j])
        if diff > max_diff:
            max_diff = diff
print(max_diff)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

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


maxi = 0

for i in A:

    for j in A:

        if i <= j and j - i > maxi:
            maxi = j - i

        elif i >= j and i - j > maxi:
            maxi = i - j

print (maxi)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
for combi in itertools.combinations(a_list, 2):
    ans = max(ans, abs(combi[1] - combi[0]))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
li = list(map(int,input().split()))
if(li[0]>li[1]):
    max=li[0]
    min=li[1]
else:
    max=li[1]
    min=li[0]
for i in range(2,n):
    if(li[i]>max):
        max=li[i]
    if(min>li[i]):
        min=li[i]
print(max-min)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in 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:
from itertools import combinations

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

ans = 0
for n1, n2 in combinations(a, 2):
  ans = max(ans, abs(n1 - n2))

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(e) for e in input().split()]

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

main()

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())
AX = list(map(int,input().split()))
print(abs(max(AX) - min(AX)))

Submission status: Accepted

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

print(max(li) - min(li))

Submission status: Accepted

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


abc()

Submission status: Accepted

Solution code:
# 整数の入力
numbers = int(input())
#２つ目の標準入力をいれる
# こんなかんじではいる[1, 4, 6, 3]
list_numbers = list(map(int, input().split()))

#maxの値を入れる
#最初は０で定義しておく
max = 0


# for文で回して一個ずつ確かめる
for number in range(numbers):
	
	for number2 in range(numbers):
		result = list_numbers[number]-list_numbers[number2]
        #絶対値なので０未満だったらマイナスつけておく
		if result < 0:
			result = -1*result
        #いままで出てきたどの結果よりも大きい値であればmaxを更新する
		if result > max:
			max = result

print(max)

Submission status: Accepted

Solution code:

n = int(input())

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

m = 0

for i in range(n):
  for j in range(i, n):
    m = max(m, abs(a[i] - a[j]))

print(m)

Submission status: Accepted

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

Submission status: Accepted

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

mi = min(lst)
mx = max(lst)

print(abs(mx-mi))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
i = 0
B = 0
C = 100000000000000
D = 0
#B = max(A) - min(A)
#print(abs(B))
while("Treu"):
    if B < A[i]:
        B = A[i]
    if C > A[i]:
        C = A[i]
    i+=1
    if i == N :
        break
D = B - C
print(abs(D))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())

list = input().split(" ")

num_list = []

for element in list:
    num_list.append(int(element))

min = 1000000001
max = 0

for num in num_list:
    if num >= max:
        max = num
    if num <= min:
        min = num

print(max - min)

Submission status: Accepted

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

imax = max(listi)
imin = min(listi)

print(imax - imin)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
A = np.array(list(map(int, sys.stdin.readline().split())))

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

Submission status: Accepted

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

print(max(c)-min(c))

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 = input().split()
a = [int(a[i]) for i in range(n)]
d = max(a) - min(a)
print(abs(d))

Submission status: Accepted

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

Submission status: Accepted

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

N, = map(int, input().split())
L = [int(v) for v in input().split()]

print(abs(max(L) - min(L)))

Submission status: Accepted

Solution code:
n = int(input())
a_s = [int(v) for v in input().split()]
ans = max(a_s) - min(a_s)

print(ans)

Submission status: Accepted

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

m = 0
for i in range(n):
  for j in range(n):
    m = max(m, abs(a[i]-a[j]))
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

print(max([abs(x[0] - x[1]) for x in itertools.combinations(A, 2)]))

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:
def sub(i,li):
    j = i + 1
    sub_max = 0
    for k in range(len(li) - j):
        if sub_max < abs(li[j] - li[i]):
            sub_max = abs(li[j] - li[i])
        j += 1
    return sub_max

n = int(input())
li = list(map(int,input().split()))
max_num = 0
for i in range(len(li)):
    a = sub(i,li)
    if a > max_num:
        max_num = a
print(max_num)

Submission status: Accepted

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

min = A[0]
max = A[0]
for i in range(N):
  if A[i] > max:
    max = A[i]
  if A[i] < min:
    min = A[i]
print(max - min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
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())
a = list(map(int,input().split()))
maxa = 0
for i in range(n-1):
    for j in range(i+1,n):
        temp = abs(a[i]-a[j])
        if temp > maxa:
            maxa = temp
print(maxa)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print (max(l)-min(l))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    for j in range(n):
        ans.append(abs(A[i] - A[j]))

print(max(ans))

Submission status: Accepted

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

for i in A:
    A1 = i
    for j in A:
        A2 = j
        a.append(abs(A1 - A2))
print(max(a))

Submission status: Accepted

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

for ai in a:
    for aj in a:
        diff.append(abs(ai - aj))
print(max(diff))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N = int(input())
	A = list(map(int, input().split(" ")))
	
	ans = max(A) - min(A)
	
	print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    _ = input()
    A = [int(x) for x in stdin.readline().split()]
    print(max(A) - min(A))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())

l=list(map(int,input().split()))
print(max(l)-min(l))

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()))

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=[int(i) for i in 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(a[len(a)-1]-a[0])

Submission status: Accepted

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

Submission status: Accepted

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

A_min = min(A)
A_max = max(A)

print(A_max - A_min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N= int(input())
    A_list = list(map(int, input().split()))

    min_A = min(A_list)
    max_A = max(A_list)
    
    print(max_A - min_A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力
N=input()
l=list(map(int,input().split()))

mx=0
for x in l:
  for y in l:
    mx=max(mx,abs(x-y))

# 出力
print(mx)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())
A = [int(i) for i in input().split()]

max_ = max(A)
min_ = min(A)
print(max_ - min_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
num_list = sorted([ int(v) for v in input().split() ])
print(num_list[-1]-num_list[0])

Submission status: Accepted

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

tmp = 0
for i in range(N):
    a1 = A[i]
    for j in range(N):
        a2 = A[j]
        if tmp < abs(a1 - a2):
            tmp = abs(a1 - a2)

print(tmp)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
A = sorted([int(i) for i in input().split()])

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

Submission status: Accepted

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

min_A = float('inf')
max_A = -1

for i in range(N):
    if A[i] < min_A:
        min_A = A[i]
    if A[i] > max_A:
        max_A = A[i]


print(max_A - min_A)

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, A: "List[int]"):
    print(max(A)-min(A))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import statistics

def main():
    num = int(input())
    data = list(map(int, input().split()))
    data.sort()
    print(data[-1] - data[0])



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
#!/bin/python3

N = int(input())

vals = [int(i) for i in input().split()]

ma = max(vals)
mi = min(vals)

print(abs(ma-mi))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(t) for t in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()
    print(max(a) - min(a))

solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
li = input().split()
li = [int(s) for s in li]
l=len(li)
 
ans = 0

for m in range(l):
    for n in range(l):
        x = abs(li[n]-li[m])
        if x>ans:
            ans = x;
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
diff = 0
a = [int(x) for x in input().split()]
for i in range(n):
    for j in range(i+1,n):
        d = abs(a[i]-a[j])
        if d > diff:
            diff = d
print(diff)

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:
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    As = sorted(As)
    print(As[-1] - As[0])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

min_number = 10 ** 10
max_number = 0

for k in A:
    if k > max_number:
        max_number = k
    if k < min_number:
        min_number = k

print(max_number - min_number)