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()))
ma = -1
mi = 1 + 10 ** 9
for i in range(n):
    if a[i] > ma:
        ma = a[i]
    if a[i] < mi:
        mi = a[i]
print(ma - mi)

Submission status: Accepted

Solution code:
n = 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 = sorted(A)
ans = A[N-1] - A[0]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

max = max(list)
min = min(list)

print(max - min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fileinput

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    _ = 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())
A = list(map(int, input().split()))

ans = abs(max(A) - min(A))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
max_abs = 0
for i in A:
    for j in A:
       max_abs = max(max_abs, abs(i - j))
print(max_abs)

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

MaxA = max(A)
MinA = min(A)

print(MaxA-MinA)

Submission status: Accepted

Solution code:
N = int(input())

A = list(input().split())
A_lis = [int(n) for n in A]

print(max(A_lis) - min(A_lis))

Submission status: Accepted

Solution code:
def actual(N, a_list):
    s = set(a_list)
    
    return max(s) - min(s)


N = int(input())
a_list = map(int, input().split())

print(actual(N, a_list))

Submission status: Accepted

Solution code:
def actual(N, a_list):
    s = set(a_list)
    num_max = max(s)
    num_min = min(s)

    return abs(num_max - num_min)


N = int(input())
a_list = map(int, input().split())

print(actual(N, a_list))

Submission status: Accepted

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

print(max(S) - min(S))

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:
_,*a=map(int,open(0).read().split());print(max(a)-min(a))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())
A = list(map(int, input().split(' ')))

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

print(max-min)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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())
arr = list(map(int,input().split()))
print(max(abs(max(arr)-min(arr)), abs(min(arr)-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:
N = int(input())
list = list(map(int, input().split()))
Max = max(list)
Min = min(list)
print(Max - Min)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

N = 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[n-1]-a[0])

Submission status: Accepted

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

c = 0
ans = []

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

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    print(max(L) - min(L))


if __name__ == "__main__":
    main()

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())
s=sorted(list(map(int,input().split())))
max=s[n-1]
min=s[0]
print(max-min)

Submission status: Accepted

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

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):
        x = abs(a[i]-a[j])
        ans = max(ans, x)
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:
# 4問目類題2
N = int(input())
L = list(map(int, input().split()))
print(max(L)-min(L))

Submission status: Accepted

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

Submission status: Accepted

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

ans = max(lis) - min(lis)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
m = -float('inf')
for i in range(n-1):
    for j in range(i+1, n):
        if abs(A[i]-A[j]) > m:
            m = abs(A[i]-A[j])

print(m)

Submission status: Accepted

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

print(max(items) - min(items))

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

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = max(A_arr)-min(A_arr)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
a=LI()
print(max(a)-min(a))

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:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
A = inputlist()
A.sort()
print(A[-1] - A[0])

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

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

Submission status: Accepted

Solution code:
# ABC102B

import numpy as np
n = int(input())
a = [int(x) for x in input().split()]
print(np.amax(abs(np.subtract.outer(a, a))))

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
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 a in A:
    for b in A:
        ans = max(ans, abs(a - b))
print(ans)

Submission status: Accepted

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

print(largest)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
a=input().split()
a=[int(x) for x in a]

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

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())
list_ai = list(map(int,input().split()))
list1 = sorted(list_ai)
print(abs(list1[N-1]-list1[0]))

Submission status: Accepted

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

ans = 0

for x in a:
    for y in a:
        if ans<abs(x-y):
            ans = abs(x-y)


print(ans)

Submission status: Accepted

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

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, 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()))
s=0
for i in range(n):
    for j in range(i+1,n):
        if abs(a[j]-a[i])>s:
            s=abs(a[j]-a[i])
print(s)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    A = sorted(N)

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


resolve()

Submission status: Accepted

Solution code:
import sys
import os
import math
import string
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N = ii()
    A = il()
    print(abs(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()))

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 = 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 = []
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:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

maxi = 0
mini = float('inf')

for i in range(n):
  maxi = max(maxi, lst[i])
  mini = min(mini, lst[i])
  
print(maxi - mini)

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()]
A.sort()
dif = A[N-1]-A[0]
print(dif)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce 
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
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(abs(max(a) - min(a)))

Submission status: Accepted

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

num_min = nums[0]
num_max = nums[0]
for item in nums:
  if item < num_min:
    num_min = item
  if item > num_max:
    num_max = item

print(num_max - num_min)

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

max = A[0]
min = A[0]

for i in range(n):
    if A[i] > max:
        max = A[i]
    elif A[i] < min:
        min = A[i]


print(max-min)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


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


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

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

Submission status: Accepted

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

print(abs(max(a_lst) - min(a_lst)))

Submission status: Accepted

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

max = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

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[-1]-a[0])

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in 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()))
a.sort()
print(a[n-1]-a[0])

Submission status: Accepted

Solution code:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    n = II()
    aa = MII()
    aa.sort()
    print(aa[-1]-aa[0])

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = list(map(int, stdin.readline().rstrip().split()))

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

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

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()))
A1 = A.copy()
for i in range(N):
  if A[i] < 0:
    A.remove(A[i])
print(max(A)-min(A))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

MAX=max(a)
MIN=min(a)
print(MAX-MIN)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = -10000000000

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


# Generated by 1.1.6 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():
    N = int(input())
    a = sorted(list(map(int,input().split())))
    print(a[-1] - a[0])
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = input().split()
p = [int(w) for w in s]

print(max(p) - min(p))

Submission status: Accepted

Solution code:
N = int(input())
l = [int(x) for x in input().split()]
m = []
for i in l:
  for j in l:
    ans = abs(i - j)
    m.append(ans)
    
print(max(m))

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    n=input()
    a=list(map(int,input().split()))
    amax=max(a)
    amin=min(a)
    print(amax-amin)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
a = list(map(int,input().split()))
min = pow(10,9)
max =  1
for i in a:
    if i<min:
        min = i
    if i>max:
        max = i
print(max-min)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# solution
import io

data=int(input())
array=list(map(int,input().split()))
highest=max(array)
lowest=min(array)
print(highest-lowest)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
T=[]
for t in range(N-1):
    for s in range(t,N):
        T.append(abs(A[t]-A[s]))
print(max(T))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(a)for a in input().split()]
    A.sort()
    print(abs(A[-1] - A[0]))
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:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

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

Submission status: Accepted

Solution code:
# ABC 102: B – Maximum Difference
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 = input()
Ai = A.split()

y = 0

for i in Ai:
  i = int(i)
  for I in Ai[1:N+1]:
    I = int(I)
    x = abs(I-i)
    if x > y:
      y = x
      
print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()
A = [int(x) for x in A]
c = abs(A[0]-A[1])
for i in range(N):
  a = A[i]
  for j in range(i+1,N):
    b = A[j]
    c = max(c,abs(a-b))
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

print(max(A_list)-min(A_list))

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

max = 0
for i in range(n):
  if i > 0:
    for j in range(i):
        max1 = abs(a[i] - a[j])
        if max1 > max:
            max = max1

print(max)

Submission status: Accepted

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

A.sort()
A.reverse()
ans = A[0] - A[len(A)-1]

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

a = min(li)
b = max(li)

print(b-a)

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()
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(abs(a[0] - a[n-1]))

Submission status: Accepted

Solution code:
n=int(input())
Min=1000000001
Max=0
t=list(map(int,input().split()))
i=0
while i<n:
    if(t[i]>Max):
        Max=t[i]
    if(t[i]<Min):
        Min=t[i]
    i=i+1
print(Max-Min)