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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=sorted(map(int,input().split()))
print(s[-1]-s[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 = 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 = sorted(A)

print(max(B)-min(B))

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

Submission status: Accepted

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

Submission status: Accepted

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

mina = min(lista)
maxa = max(lista)

ans = abs(maxa-mina)
print(ans)

Submission status: Accepted

Solution code:
def actual(N, A):
    return abs(max(A) - min(A))

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

print(actual(N, A))

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = i()
A = l()
print(max(A)-min(A))

Submission status: Accepted

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

lis = sorted(lis)

print(abs(lis[0] - lis[n-1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for a, b in combinations(A, 2):
        ans = max(ans, abs(a - b))
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def MI():
    return map(int, input().split())

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

N = int(input())
A = LI()
A.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

maximum_difference = max(list) - min(list)

print(maximum_difference)

Submission status: Accepted

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

Submission status: Accepted

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

Max=0
Min=10**9

for i in range(n):
    if(Max<a[i]):
        Max=a[i]
    if(Min>a[i]):
        Min=a[i]

print(abs(Max-Min))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[-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):
        if i!=j:
            x=int(a[i]-a[j])
            y=abs(x)
            if max<=y:
                y
                max=y


print(max)

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):
        if i!=j:
            x=int(a[i]-a[j])
            if x<0:
                x *=-1
                if max<=x:
                    max=x


print(max)

Submission status: Accepted

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

m=[]
for i in range(n):
    for j in range(n):
        if i!=j:
            m.append(abs(l[i]-l[j]))
            
print(max(m))

Submission status: Accepted

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

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

l = max(s)
m = min(s)
print(l-m)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(mx)

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

Submission status: Accepted

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

maxs = max(b)
mins = min(b)

print(maxs-mins)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
A=list(map(int,input().split()))
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())
ans = 0
A=list(map(int,input().split()))
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()))
s = 0
for i in range(n):
    for j in range(n):
        t = abs(A[i]-A[j])
        if s <= t:
            s = t
print(s)

Submission status: Accepted

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

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:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ma = max(a)

mi = min(a)


print(abs(mi-ma))

Submission status: Accepted

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

ANS = []
for i in range(len(A)):
  for j in range(i,len(A)):
    ANS.append(abs(A[i] - A[j]))
    
print(max(ANS))

Submission status: Accepted

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

    min = None
    max = None

    for a in A:
        if min is None or min > a:
            min = a
        if max is None or max < a:
            max = a

    print(max - min)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#MaximumDifference
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())
a = list(map(int, input().split()))
s = set()
for i in range(n):
  for j in range(n):
    if i != j:
      s.add(abs(a[i] - a[j]))
print(max(list(s)))

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

if len(A) == 1:
    print(0)
else:
    nc2 = combinations(A, 2)

    max_sub = max(
        [
            max(a - b, b - a)
            for a, b in nc2
        ]
    )

    print(max_sub)

Submission status: Accepted

Solution code:
N = int(input())
*A, = 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()))
print(max(a)-min(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = tuple(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()]

A = sorted(A)

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

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(map(int, input().split()))
m = -10*100


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

print(m)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
k = len(a)
max = 0

for i in range(k):
    for j in range(i + 1, k):
        abs_ = abs(a[i] - a[j])
        if abs_ > max:
            max = abs_

print(max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    A = list(map(int,input().split()))
    ans = -INF
    for i in range(N):
        for j in range(i + 1,N):
            ans = max(ans,abs(A[i] - A[j]))
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = 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()))
dmax = 0
for i in range(n-1):
    for j in range(i+1,n):
        dmax = max(dmax, abs(A[i]-A[j]))
print(dmax)

Submission status: Accepted

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

dmax = 0
for i in range(n-1):
    for j in range(i+1,n):
        # print(i,j)
        d = abs(A[i]-A[j])
        dmax = max(dmax, d)
        # print('Ai',A[i],'Aj',A[j],'d',d,'dmax',dmax)
        # print('---')

print(dmax)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in a:
    for j in a:
        ans = max(ans, abs(i - j))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    res = abs(max(a) - min(a))
    print(res)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
list = sorted(map(int, input().split()))
print(list[-1] - list[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()
s=[int(i) for i in input().split()]
print(max(s)-min(s))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int , input().split()))
ans = 0
for ai in a:
    for bi in a:
        ans = max(ans, abs(bi - ai))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Maximum Difference

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

Submission status: Accepted

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

Submission status: Accepted

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

while True:
    for i in range(N):
        a = abs(A[b] - A[i])
        if a > ans:
            ans = a
    b = b + 1
    if b == N - 1:
        break
    else :
        continue
    break      
print(ans)

Submission status: Accepted

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

lis.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 abs(A[i] - A[j]) > max:
            max = abs(A[i] - A[j])
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(max(A)-min(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

max_value = max(A);
min_value = min(A);

sub = abs(max_value - min_value)

print(sub)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
answer = A.max() - A.min()
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input()) 
a = list(map(int, input().split()))
print(abs(max(a) - min(a)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().rstrip("\n"))
l = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
l.sort()
print(l[-1]-l[0])

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N = inputI()
A = inputIL()
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:
input()
min_ = float('inf')
max_ = 0
for i in map(int, input().split()):
    if min_ > i:
        min_ = i
    if max_ < i:
        max_ = i
print(max_ - min_)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
A = LI()
ans = -INF
for x, y in combinations(A, 2):
    ans = max(ans, abs(x-y))
print(ans)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import bisect
import re

def solve(A):
    return max(A) - min(A)

def main():
    n = int(input())
    A = list(map(int, input().split()))
    print(solve(A))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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 B

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

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

print(max([abs(pair[0] - pair[1])for pair in combinations(A, r=2)]))

Submission status: Accepted

Solution code:
import math

N = int(input())
A_num = list(map(int, input().split()))
sum = []
for i in range(N):
    for j in range(N):
        sum.append(math.fabs(A_num[i] - A_num[j]))

print(int(max(sum)))