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())
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())
a = list(map(int, input().split()))
dist = []
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dist.append(abs(a[i]-a[j]))
print(max(dist))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

arr = []
for v in combinations(a,2):
    arr.append(abs(v[0]-v[1]))

print(max(arr))

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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = lst[0]
val_min = lst[0]
for i in lst:
  if val_max < i:
    val_max = i
  elif val_min > i:
    val_min = i
  
print(val_max-val_min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    list_length = int(input())
    num_list = list(map(int, input().split(" ")))
    answer = -float("inf")
    for i in range(list_length):
        for j in range(i, list_length):
            answer = max(answer, abs(num_list[i] - num_list[j]))
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
try:
  N = int(input())
  a = list(map(int, input().split()))
  a_ = sorted(a)
  print(a_[len(a_)-1]-a_[0])
  
except EOFError:
  pass

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

infinity = float('inf')
min = infinity
max = -1

for i in a_list:
    if i > max:
        max = i
    if i < min:
        min = i

print(max - min)

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc102/tasks/abc102_b
# Python 3rd Try
import sys


def solve(cells):
    answer = 0
    cells.sort(reverse=True)
    answer = cells[0] - cells[-1]
    return answer


if __name__ == "__main__":
    X = list(map(int, sys.stdin.readline().split()))
    AI = list(map(int, sys.stdin.readline().split()))
    print(solve(AI))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 5分くらい.easy.

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

x = 0
for i in range(0,n-1):
    for j in range(i,n):
        x = max(abs(l[i] - l[j]), x)
print(x)

Submission status: Accepted

Solution code:


n = int(input())
l = list(map(int, input().split()))
#print(n,l)
x = 0
for i in range(0,n-1):
    for j in range(i,n):
        #print(abs(l[i] - l[j]))
        x = max(abs(l[i] - l[j]), x)
print(x)

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())
numbers = [int(i) for i in input().split()]

max_num = max(numbers)
min_num = min(numbers)

print(abs(max_num - min_num))

Submission status: Accepted

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

MAX = max(raw)
MIN = min(raw)

ans = abs(MAX - MIN)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int, input().split()))
Ans=[]
for i in range(N):
    for k in range(N):
        t=A[k]-A[i]
        t2=abs(t)
        Ans.append(t2)
print(max(Ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc102/tasks/abc102_b
# Python 2nd Try
import sys


def solver(allN, numberList):
    answer = 0
    for j in range(0, allN):
        for k in range(0, allN):
            nowAbs = (numberList[j] - numberList[k]).__abs__()
            if answer < nowAbs:
                answer = nowAbs
    return answer


if __name__ == "__main__":
    N = sys.stdin.readline().rsplit()
    Ai = list(map(int, sys.stdin.readline().split()))
    answer = solver(int(N[0]), Ai)
    print(answer)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
print(sa[len(a)-1]-sa[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 , *A = map(int,open(0).read().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 = [int(i) for i in input().split()]

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

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):
        a = abs(A[i]-A[j])
        ans = max(ans,a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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()))
max=max(A)
min=min(A)
res=max-min
print(res)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

readline()
a = list(map(int,readline().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:
import sys
s=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()))
a.sort()
print (abs(a[-1]-a[0]))

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 = [int(x) for x in input().split()]

aa = sorted(a)
ans = aa[n-1]-aa[0]
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=list(map(int,input().split()))
S.sort()
print(S[-1]-S[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):
        if abs(a[i]- a[j]) > ans:
            ans = abs(a[i]- a[j])
print(ans)

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(i+1, n):
    ans=max(ans, abs(a[i]-a[j]))
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline().split()[0])
a = list(map(int,input().split()))
a.sort()
print(a[-1]-a[0])

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

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc102/tasks/abc102_b
# Python 1st Try
import sys


def solve(N, givenList):
    answer = 0
    sortedList = sorted(givenList, reverse=True)
    answer = sortedList[0]-sortedList[-1]
    return answer


if __name__ == "__main__":
    N = int(sys.stdin.readline())
    Ai = list(map(int, sys.stdin.readline().split(' ')))
    print(solve(N, Ai))

Submission status: Accepted

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

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())
li = list(map(int, input().split()))
li = sorted(li, reverse=True)
ans = li[0] - li[n-1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ais = list(map(int, input().split()))
a_mini = ais[0]
a_max = ais[0]
for i in range(1, n):
  if ais[i] < a_mini:
    a_mini = ais[i]
  if ais[i] > a_max:
    a_max = ais[i]
print(a_max - a_mini)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

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

N, *A = map(int, read().split())
A.sort()
print(A[-1]-A[0])

Submission status: Accepted

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


Diff = []
for i in range(N):
    stv = A[i]
    for i in range(N):
        x = stv - A[i]

        Diff.append(abs(x))
    
print(max(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:
n = int(input())
a = list(map(int, input().split()))
diff = [0]*(n**2 - n)
count = -1

for i in range(n):
  for ii in range(n-i-1):
    count = count + 1
    diff[count] = abs(a[i] - a[i+ii+1])
print(max(diff))

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()))
ans=max(a)-min(a)
print(ans)

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

ans = -1
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()))
LA = 0
for i in range(0,N):
  for j in range(i+1,N):
    if abs(A[j]-A[i]) >= LA:
      LA = abs(A[j]-A[i])
print(LA)

Submission status: Accepted

Solution code:
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 = max(A) - min(A)

print(ans)

Submission status: Accepted

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

minA = min(A)
maxA = max(A)

print(maxA-minA)

Submission status: Accepted

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

for i in range(N):
  if a[i]<minimum:
    minimum=a[i]
  if a[i]>max:
    max=a[i]

print(max-minimum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
D = []
A.sort()
min_A = A[0]
A.sort(reverse=True)
max_A = A[0]
print(max_A - min_A)

Submission status: Accepted

Solution code:
_ = int(input())
nums = list(map(int, input().split()))
max_n = 0
min_n = 100000000000000000000000
for i in nums:
	if max_n < i:
		max_n = i
	if min_n > i:
		min_n =i
print(max_n - min_n)

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:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().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[-1]-A[0])

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

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

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

Submission status: Accepted

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

sorted_A = sorted(A)

#ソートして最後から最初を引く
print(sorted_A[-1]-sorted_A[0])

Submission status: Accepted

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

Submission status: Accepted

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

a.sort(reverse=True)

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

Submission status: Accepted

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

a.sort(reverse=True)

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

print(ans)

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 = [int(x) for x 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(abs(A[0] - A[-1]))

Submission status: Accepted

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

# m = -1
# for i in range(N-1):
#     for j in range(i+1, N):
#         m = max(abs(As[i] - As[j]), m)
# print(m)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

l.sort()

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

Submission status: Accepted

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

# diff = 0
# maxNum = 0
# maxDiffArray = []
# for i in range(len(L)):
#     diffArray = []
#     for j in range(len(L)):
#         if i != j:
#             diff = abs(L[i] - L[j])
#             diffArray.append(diff)
#     maxDiffArray.append(max(diffArray))
# print(max(maxDiffArray))

# 別解：数列の最大値と最小値の差が要素間の差の最大値となることを利用
print(max(L) - min(L))

Submission status: Accepted

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

diff = 0
maxNum = 0
maxDiffArray = []
for i in range(len(L)):
    diffArray = []
    for j in range(len(L)):
        if i != j:
            diff = abs(L[i] - L[j])
            diffArray.append(diff)
    maxDiffArray.append(max(diffArray))
print(max(maxDiffArray))

Submission status: Accepted

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

N = int(input())
array = list(map(int, input().split()))
array.sort()
ans = array[N-1]-array[0]
print(ans)

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

new = sorted(li)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
As = list(map(int, input().split()))
As.sort()

print(As[-1] - As[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:
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
input = sys.stdin.readline
N = int(input())
li = [int(i) for i in input().split()]
li.sort()
print(li[-1] - li[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import fractions
import heapq
import sys
import re
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
A=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

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

Submission status: Accepted

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

max = 0

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

Submission status: Accepted

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

max_ = -1
for i in range(n):
    for j in range(i+1, n):
        tmp = abs(lst[i] - lst[j])
        if tmp > max_:
            max_ = tmp
print(max_)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
A = list(map(int, input().split()))
A.sort()

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

a.sort(reverse=True)
print(abs(a[n-1]-a[0]))

Submission status: Accepted

Solution code:
#102 b-maximum difference
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=a[-1]-a[0]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    a.sort()
    return a[-1] - a[0]

if __name__ == '__main__':
    ans = main()
    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):
        x=abs(a[i]-a[j])
        if x>ans:
            ans=x
print(ans)

Submission status: Accepted

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

min_diff = 0
for i in itertools.product(A, repeat=2):
    min_diff = max(min_diff, abs(i[0]-i[1]))
print(min_diff)

Submission status: Accepted

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

ma,mi = 0,10**9

for i in lst1:
    ma = max(ma,i)
    mi = min(mi,i)

print(abs(ma-mi))

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
max_ans = 0
for i in range(N):
    for j in range(N):
        ans = abs(A[i]-A[j])
        if(max_ans < ans):
            max_ans = ans

print(max_ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
print(A[-1] - A[0])

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

##Just for prctice
n=int(input())

A=[int(i) for i in input().split()]
ans=-1
for i in range(0,n-1):
    for k in range(i+1,n):
        ans=max(ans,abs(A[i]-A[k]))

print(ans)


"""
4
1 4 6 3

5

2
1000000000 1

999999999

5
1 1 1 1 1

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:
# -*- coding: utf-8 -*-


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()))
B = list()
for i in range(N):
  B.append(abs(A[i]))
print(max(B)-min(B))

Submission status: Accepted

Solution code:
N = int(input())
A = input()
A = A.split()
L = len(A)
B =[]
for i in range(L):
    B.append(int(A[i]))
B.sort(reverse=True)
ans = B[0] - B[L-1]

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()))
max = 0
min = 10**10

for x in A:
    if x > max:
        max = x
    if x < min:
        min = x

print(max - min)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
temp = []
for i in range(0, N):
    for j in range(i, N):
        temp.append(abs(A[i]-A[j]))

print(max(temp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 math

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

Submission status: Accepted

Solution code:
import sys
n = int(input())

l = list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
a_L = map(int,input().split())

a_L = sorted(a_L)
print(abs(a_L[0]-a_L[-1]))

Submission status: Accepted

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

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

print(res)

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())
ln=[int(n) for n in map(int,input().split())]
print(max(ln)-min(ln))

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())
l=list(map(int,input().split()))
l.sort()
print(l[-1]-l[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools as it

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

ans = 0

# 初期化
diff = 0

for x1,x2 in list(it.combinations(A,2)):
        if (diff < abs(x1 - x2)):
                diff = abs(x1 - x2)

print(diff)

Submission status: Accepted

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

Submission status: Accepted

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

print(max(ll)-min(ll))

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=input()
A=[int(a) for a 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[-1] - A[0]))

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
A = [int(num) for num in input().split()]

combs = combinations(A, 2)

ret = 0
for comb in combs:
    if abs(comb[0] - comb[1]) > ret:
        ret = abs(comb[0] - comb[1])

print(ret)

Submission status: Accepted

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

A_new = sorted(A)

print((A_new[-1]) - (A_new[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 = []
for i in range(N - 1):
  for j in range(i + 1,N):
    ans.append(abs(A[i] - A[j]))
    
print(max(ans))

Submission status: Accepted

Solution code:
n = int(input())
line = map(int,input().split(" "))
nums = list(line)
ma = max(nums)
mi = min(nums)
answer = ma - mi
print(answer)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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()))
a.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in l:
    for j in l:
        if abs(i - j) >= zet:
            zet = abs(i-j)

print(zet)

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:
input(); [print(max(list_) - min(list_)) for list_ in [list(map(int, input().split()))]]

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
a = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(lst) - min(lst))

Submission status: Accepted

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