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

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

Submission status: Accepted

Solution code:
if __name__=="__main__":
  N = int(input())
  A = map(int, input().split())
  sortedA = sorted(A);
  print(sortedA[-1]-sortedA[0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

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

print(A_max - A_min)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
str_n = input()
n = int(str_n)
str_a = input()
arr_a = str_a.split(' ')
arr_ia = []
for item in arr_a:
    arr_ia.append(int(item))

arr_ia.sort()
print(int(arr_ia[-1]) - int(arr_ia[0]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().strip().split()))
min_n = max_n = A[0]
for i in range(1, N):
	num = A[i]
	if min_n > num:
		min_n = num
	if max_n < num:
		max_n = num
result = max_n - min_n
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input()
a=input().split()
b=[]
m=0

for x in a:
  b.append(int(x))

for y in b:
  for z in b:
    c=abs(y-z)
    if m<c:
      m=c

print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    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())
A = list(map(int, input().split()))

print('{0:d}'.format(max(A) - min(A)))

Submission status: Accepted

Solution code:
import itertools as iter

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

print(max([abs(a-b) for a,b in iter.combinations(A, 2)]))

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
print(A.max() - A.min())

Submission status: Accepted

Solution code:
def abs(x):
    if x > 0:
        return x
    else:
    	return x * (-1)

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a_sorted = sorted(a)
    print(abs(a_sorted[-1] - a_sorted[0]))

Submission status: Accepted

Solution code:
number = input()
b = input()
b = b.split()
c=[]

for i in b:
    c.append(int(i))

b_max=max(c)
b_min=min(c)

print(b_max - b_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())
s = input().split()
s1 = [int(s) for s in s]

lst = sorted(s1)

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

Submission status: Accepted

Solution code:
N = int(input())
listN = input().split()
i = 0
while i < N:
    listN[i] = int(listN[i])
    i += 1
print(max(listN) - min(listN))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

maxv = -1

for i in range(n):
    for j in range(n-1):
        if i == j:
            continue
        if abs(a[i]-a[j]) > maxv:
            maxv = abs(a[i]-a[j])


print(maxv)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
list1=[int(i) for i in input().split()]
list2=[]
for i in range(N):
    for j in range(i):
        list2.append(abs(list1[i]-list1[j]))
print(max(list2))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
mini=l[0]
maxi=l[0]
for i in l:
    if mini > i:
        mini =i
    if maxi < i:
        maxi=i
print(maxi-mini)

Submission status: Accepted

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

# print(A)
maximum = max(A)
minimum = min(A)

print(maximum - minimum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

result = 0
for Ai in range(len(As) - 1):
    for Aj in range(Ai + 1, len(As)):
        result = max(result, abs(As[Ai] - As[Aj]))

print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline().rstrip("\n")

    while line:
        N = int(line)
        A = [int(a) for a in raw_input().rstrip("\n").split(" ")]
        sorted_A = sorted(A)
        distance = abs(sorted_A[-1] - sorted_A[0])
        print(distance)
        line = sys.stdin.readline().rstrip("\n")

if __name__ == "__main__":
    main(sys.argv)

Submission status: Accepted

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

array.sort()
print(array[n-1] - array[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()))
max = 0
for i in range(n):
    for j in range(i,n):
        c = abs(a[i]-a[j])
        if(max < c):
            max = c
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)

xs = [int(x) for x in input().split()]

print(max(xs) - min(xs))

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:
def main():
    N = int(raw_input())
    list_A = map(int, raw_input().split(' '))

    sorted_A = sorted(list_A)
    print sorted_A[-1] - sorted_A[0]

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  1 20:09:43 2018
ABC102B
@author: maezawa
"""

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

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

print(d)

Submission status: Accepted

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

Submission status: Accepted

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

max_difference = 0

for i, n1 in enumerate(n_list):
  for j, n2 in enumerate(n_list):
    if i == j:
      continue
    diff = n2 - n1
    max_difference = max(max_difference, diff)

print(max_difference)

Submission status: Accepted

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

n = int(raw_input())
a = np.array(map(int,raw_input().split()))

ma = np.max(a)
mi = np.min(a)

print ma-mi

Submission status: Accepted

Solution code:
import  math

n = int(input())
arr = input().split(" ")
numbers = []
for i in range(0,len(arr)):
    numbers.append(int(arr[i]))

maxdiff = 0

for i in range(0,len(numbers)):
    for j in range(i, len(numbers)):
        diff = abs(numbers[i]-numbers[j])
        if diff > maxdiff:
            maxdiff = diff
print(maxdiff)

Submission status: Accepted

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

max_a = max(a)
min_a = min(a)

print(max_a - min_a)

Submission status: Accepted

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

Submission status: Accepted

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

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

Amax = max(An)
Amin = min(An)

print(Amax - Amin)

Submission status: Accepted

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

maxA = A[len(A)-1]-A[0]

print(maxA)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(" ")))

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

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

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

for i in range(n):
	a[i] = int(a[i])

x = max(a)
y = min(a)

print(x-y)

Submission status: Accepted

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

a_list.sort()

a_min=a_list[0]
a_max=a_list[-1]

print(a_max-a_min)

Submission status: Accepted

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

min_ = 10**9
max_ = 0

for a in A:
  min_ = min(min_, a)
  max_ = max(max_, a)

print(abs(max_ - min_))

Submission status: Accepted

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

max_a = max(A)
min_a = min(A)

ans = max_a - min_a
print(ans)

Submission status: Accepted

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

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 = input().strip().split(' ')
A = [int(x) for x in A]
print(max(A) - min(A))

Submission status: Accepted

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

ans = 0
for j in range(len(A) - 1):
  for k in range(j + 1, len(A)):
    ans = max(ans, abs(A[j] - A[k]))
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
la=list(map(int,input().split()))
maxdiff=0
for i in range(N):
    for j in range(N):
        if(maxdiff<abs(la[i]-la[j])):
            maxdiff=abs(la[i]-la[j])
print(maxdiff)

Submission status: Accepted

Solution code:
#coding: utf-8

MAX = 10 ** 9

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split(" ")))
    max,min=(1,MAX)
    for i in range(n):
        if a[i] < min:
            min = a[i]
        if a[i] > max:
            max = a[i]
    
    print(max - min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
 
mn = 10 ** 9
mx = 0
 
for i in range(n):
  if a[i] < mn:
    mn = a[i]
    
  if a[i] > mx:
    mx = a[i]
  
print(mx - mn)

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

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

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 = input().split()
A = []
for i in range(N):
    A.append(int(a[i]))
print(max(A)-min(A))

Submission status: Accepted

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

re = max(A) - min(A)

print(re)

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

min_input = input_list[0]
max_input = input_list[0]

for i in input_list[1:num_args]:
  if i < min_input:
    min_input = i
  elif i > max_input:
  	max_input = i
    
print(abs(max_input-min_input))

Submission status: Accepted

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

Submission status: Accepted

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

#sort
A.sort()

#max-min
print(A[-1]-A[0])

Submission status: Accepted

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

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

ma = max(a)
mi = min(a)

print(ma - mi)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(max(aa) - min(aa))

Submission status: Accepted

Solution code:
N = int(input())

A = tuple(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.sort()
print(a[n - 1] - a[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

An.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
print(abs(a[-1] - a[0]))

Submission status: Accepted

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

Submission status: Accepted

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

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

AN.sort()

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

Submission status: Accepted

Solution code:
_ = input()
nums = list(map(int, input().split(" ")))
n_min, n_max = min(nums), max(nums)
print(n_max - n_min)

Submission status: Accepted

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

ma = 0
for i in range(len(A)):
    for j in range(len(A)):
        if i != j:
            ma = max(ma, abs(A[i] - A[j]))
print(ma)

Submission status: Accepted

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

Submission status: Accepted

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

    result = max(array) - min(array)

    print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

maxabs = 0

for i in range(n - 1):
    for j in range(i, n):
        v = abs(a[i] - a[j])
        if v > maxabs:
            maxabs = v

print(maxabs)

Submission status: Accepted

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

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

print(maxdiff)

Submission status: Accepted

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

lst = []
for i in range(n):
    for j in range(n):
        lst.append(abs(a[i]-a[j]))

lst.sort()
print(lst[-1])

Submission status: Accepted

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

a.sort()

ans = a[n-1] - a[0]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
a=list(map(int, input().split(" ")))
print(np.max(a)-np.min(a))

Submission status: Accepted

Solution code:
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_b


N = int(input())

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

mini = 10**9
maxi = 1
for i in a:
    if i < mini:
        mini = i
    if maxi < i:
        maxi = i

print(maxi - mini)

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

arr = map(int,raw_input().split())


ans = 0
for i in range(n):
	for j in range(n):
		if i != j:
			ans = max(ans,abs(arr[i]-arr[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())
A = [int(i) for i in input().split()]

M = max(A)
m = min(A)
print(abs(M-m))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
print(abs(A_list[-1] - A_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 = int(input())
A = list(map(int, input().split()))

a_min = min(A)
a_max = max(A)

print(a_max - a_min)

Submission status: Accepted

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

Submission status: Accepted

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

max_n = max(a)
min_n = min(a)

if abs(max_n - min_n) > abs(min_n - max_n):
    print(abs(max_n - min_n))
else:
    print(abs(min_n - max_n))

Submission status: Accepted

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

    dif_max = -1
    for i in range(n):
        for j in range(n):
            if abs(a[i]-a[j]) > dif_max and i != j:
                dif_max = abs(a[i]-a[j])

    print(dif_max)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    xs = [int(s) for s in input().split()]
    print(max(xs) - min(xs))

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

a = max(A)
b = min(A)

ans = abs(a - b)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
from sys import stdin


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=map(int,input().split())
b=0
c=10**9
for i in a:
    b=max(i,b)
    c=min(i,c)
print(b-c)

Submission status: Accepted

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

print(max(inp) - min(inp))

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

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

Submission status: Accepted

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


M = max(A)
m = min(A)

print(M-m)

Submission status: Accepted

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

Submission status: Accepted

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

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

    ans = f(N, A)
    print(ans)


def f(N, A):
    ans = -float("inf")
    for i, a1 in enumerate(A):
        for j, a2 in enumerate(A):
            if i != j:
                ans = max(ans, abs(a1 - a2))

    return ans


if __name__ == '__main__':
    main()

Submission status: Accepted

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

max = 0
min = 10 ** 9

for a in A:
    if a > max:
        max = a
    if a < min:
        min = a
print(max - min)

Submission status: Accepted

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

if max(a) - min(a) > 0:
    print(max(a)-min(a))
else:
    print(min(a) - max(a))

Submission status: Accepted

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

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

ans = -1

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=input()
A=A.rstrip().split(" ")
list1=[]
for i in range(len(A)):
    list1.append(int(A[i]))
list1.sort()
print(list1[N-1]-list1[0])

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*
N = int(input())
nums = list(map(int, input().split()))
print(max(nums)-min(nums))

Submission status: Accepted

Solution code:
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    temp1 = input()
    temp1 = input()

    temp1 = temp1.split(" ")
    
    temp1 = list(map(int,temp1))
    temp1.sort()
    
    print(abs(temp1[0]-temp1[-1]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()
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:
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(repr(item))
        stderr.write(sep)
    stderr.write(end)

n = int(input())
a = f()
abss = []
for i in range(n):
    for j in range(i,n):
        abss.append(abs(a[i] - a[j]))

print(max(abss))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
S=list(map(int,input().split()))

saishou=min(S)
saidai=max(S)
print(max(S)-min(S))

Submission status: Accepted

Solution code:
N = int(input())
*A, = 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(int(A[N-1] - A[0]))

Submission status: Accepted

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

print(max(A_l) - min(A_l))

Submission status: Accepted

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

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

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

tmp = -1

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

print(tmp)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

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

main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

max = 0

for i in range(n):
    for j in range(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 = [int(elem) for elem in input().split(' ')]
assert len(A_list) == N

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