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

A = sorted(A)

ans = A[N-1] - A[0]

print(ans)

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()))
x=[]
for i in range(n-1):
    for j in range(i+1,n):
        x.append(abs(a[i]-a[j]))
print(max(x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(li))

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

max = 0
for i in range(n):
  for j in range(i):
    m = abs(list[j] - list[i])
    if (max < m):
      max = m
      
print(max)

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(str(max(A) - min(A)))

Submission status: Accepted

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

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

max = 0

for i in range(N):
    for j in range(N-1):
        if abs(A[i]-A[j]) > max:
            max = abs(A[i]-A[j])

print(max)

Submission status: Accepted

Solution code:
n = int(input())
a_list = 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_list[i] - a_list[j]))
print(ma)

Submission status: Accepted

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

min_A = min(A)
max_A = max(A)

print(max_A-min_A)

Submission status: Accepted

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

lis = []
for i in range(len(A)):
  for j in range(len(A)):
    lis.append(abs(A[i]-A[j]))

print(max(lis))

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

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

Submission status: Accepted

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


if __name__ == '__main__':
    q2()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Alist = list(map(int,input().split()))
tmp = 0
ans = 0

for i in range(N):
  for j in range(N):
    if Alist[i] != Alist[j]:
      tmp = abs(Alist[i] - Alist[j])
    else:
      pass

    if tmp > ans:
      ans = tmp
    else:
      pass

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = int(input())
    a = [int(i) for i in input().split()] 
    
    a.sort()
    print(abs(a[0] - a[len(a)-1]))

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  _ = int(input())
  A = list(map(int,input().split()))
  
  A = sorted(A,reverse=True)
  print(abs(A[0] - A[_-1]))
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

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

num_ans = 0

for i in range(N):
  for j in range(N):
      tmp = abs(A[i] - A[j])
      if tmp > num_ans:
        num_ans = tmp

print(num_ans)

Submission status: Accepted

Solution code:
#!python3

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


def main():
    A.sort()
    ans = A[-1] - A[0]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

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

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

print(res)

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())
list_A = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans, abs(list_A[i]-list_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:
input()
s = sorted(map(int,input().split()))
print(s[-1]-s[0])

Submission status: Accepted

Solution code:
def Maximum(n , al):

    return max(al) - min(al)

def main():
    n = int(input())
    al = list(map(int , input().split()))
    print(Maximum(n , al))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def Maximum(n , al):

    return abs(max(al) - min(al))

def main():
    n = int(input())
    al = list(map(int , input().split()))
    print(Maximum(n , al))

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = sorted(iil())
print(A[-1]-A[0])

Submission status: Accepted

Solution code:
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    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
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = list(map(int, input().split()))
    res = 0
    for i in combinations(a, 2):
        res = max(res, abs(i[0]-i[1]))
    print(res)

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

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

Submission status: Accepted

Solution code:
import math

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


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

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(reverse=True)
print(a[0]-a[-1])

Submission status: Accepted

Solution code:
N = int(input())

L = list(map(int,input().split()))
L.sort()

print(L[N-1] - L[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def solve():
    _ = int(input())
    As = list(map(int, input().split()))
    print(max(As)-min(As))


# Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
num = int(input())

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

num_list.sort()

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(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()))
ans=0

for i in range(0,N):
  for j in range(i,N):
    ans = max(abs(A[i]-A[j]),ans)
    
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:
a = int(input())
L = list(map(int, input().split()))

L.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    As = sorted(list(map(int, input().split())))

    a = As[0]
    b = As[-1]

    ans = b - a
    print(ans)


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()))
ans = 0

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

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:
import itertools

N = int(input())
A = list(map(int, input().split()))
ans = list()
for i in itertools.combinations(A, 2):
  div = 0
  #print(i[0])
  if i[0] > i[1]:
    div = i[0] - i[1]
  else:
    div = i[1] - i[0]
  ans.append(div)

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

num.sort()

print(num[-1] - num[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, *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()))
ans = max(A) - min(A)
print(ans)

Submission status: Accepted

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

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()))
B=sorted(A)
print(B[N-1]-B[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())
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:
import itertools
n=int(input())
a=list(map(int,input().split()))
m=0
for v in itertools.combinations(a,2):
    m=max(abs(v[0]-v[1]),m) 
print(m)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
readline = sys.stdin.readline
n = int(readline())
a = sorted([int(x) for x in readline().strip().split(" ")])
print(int(math.fabs(a[-1] - a[0])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Thu Mar 12 07:38:24 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
a = na()

ans = -inf
for i in range(N):
    for j in range(N):
        if i != j:
            ans = max(ans, abs(a[i] - a[j]))

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a_list = list(map(int,input().split()))
a_max = 0
a_min = 10000000000

for a in a_list:
    if a > a_max:
        a_max = a
    if a < a_min:
        a_min = a

print(a_max - a_min)

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

ans = 0
for i in range(n):
    for j in range(i):
       t = abs(a[j]-a[i])
       if ans < t:
           ans = t

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int, input().split()))
L.sort()
print(L[N-1]-L[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:
def main():
  input()
  ary = list(map(int, input().split()))
  minv = maxv = ary[0]
  for v in ary:
    if v < minv:
      minv = v
    elif v > maxv:
      maxv = v
  print(str(maxv - minv))
    
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:
        ztc = abs(i - j)
        if ztc > ans:
            ans = ztc
print(ans)

Submission status: Accepted

Solution code:
#102B maximum difference
s=[[int(j) for j in input().split()] for i in range(2)]
N=s[0][0]
A=s[1]
max=0
for i in range(len(A)):
    for j in range(i,len(A)-1):
        result=A[i]-A[j+1]
        if result<0:result=result*-1
        if result>max:max=result
print(max)

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

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

Submission status: Accepted

Solution code:
from itertools import permutations


def main(n, a):
    ans = 0
    for i, j in permutations(a, 2):
        ans = max(ans, i - j)

    print(ans)


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

    main(n, a)

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

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

    print(max([abs(A[i]-A[j]) for i in range(n) for j in range(n)]))

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
maximum = a[0]
minimum = a[0]
for i in range(1,n):
    maximum = max(maximum, a[i])
    minimum = min(minimum, a[i])

print(maximum-minimum)

Submission status: Accepted

Solution code:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


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

Submission status: Accepted

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

Submission status: Accepted

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

ans = abs(n[0] - n[l-1])
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:
from itertools import combinations

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

print(max(abs(a - b) for a, b in combinations(A, 2)))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC102

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
maxi = 0
mini = float("inf")
for n in A:
  maxi = max(maxi,n)
  mini = min(mini,n)
print(maxi-mini)

Submission status: Accepted

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

Submission status: Accepted

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

max_dif = 0
for i in range(N):
  for j in range(N):
    dif = A[i] - A[j]
    if dif > max_dif:
      max_dif = dif
      
print(max_dif)

Submission status: Accepted

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

for i in range(n):
    if a[i] < 0:
        a[i] *= -1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

t.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in 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(abs(max(A) - min(A)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)
print(a.pop() - a.popleft())

Submission status: Accepted

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

A_list.sort()

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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    a=LIST()
    print(max(a)-min(a))
if __name__ == '__main__':
    do()

Submission status: Accepted

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

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

min_a = min(a)
max_a = max(a)
print(abs(min_a - max_a))

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

Submission status: Accepted

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

M = max(a)
m = min(a)

d = M-m

if d < 0:
  d = -d
else:
  pass

print(d)

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
M=0
m=float('inf')
for i in range(N):
      M=max(M,A[i])
      m=min(m,A[i])
print(M-m)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#102_B
N=int(input())
A=[int(n) for n in input().split()]
Ans=0
for i in range(N):
    for j in range(N):
        Ans=max(Ans,abs(A[i]-A[j]))
print(Ans)

Submission status: Accepted

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

n = int(input().strip())
nums = list(map(int, input().rstrip().split()))
#----------
calc=[]
for i in range(len(nums)-1):
    for j in range(i+1,len(nums)):
        calc += [ abs(nums[i] - nums[j]) ]

print(max(calc))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
l=[]
def abs(x):
    if x >=0:
        return x
    else:
        return x*(-1)
for j in range(N):
    for k in range(j+1,N):
        l.append(abs(A[k]-A[j]))
max=l[0]
for m in range(len(l)):
    if max<l[m]:
        max=l[m]
print(max)

Submission status: Accepted

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

Submission status: Accepted

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

print(max(list_A) - min(list_A))

Submission status: Accepted

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

def main():
    n = input()
    vals = list(map(int, input().split()))
    print(max(vals) - min(vals))


if __name__ == '__main__':
    main()

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()))
Max = 0

for i in range(N):
  for j in range(i, N):
    if Max < abs(a[i]-a[j]):
      Max = abs(a[i]-a[j])

print(Max)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
L = []
for i in range(N-1):
    for j in range(i+1, N):
        l = A[i] - A[j]
        abs_l = abs(l)
        L.append(abs_l)

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

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