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 python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort()
    ret = A[-1] - A[0]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()
    alist = intina()

    ans = 0

    for a in alist:
        for b in alist:
            ans = max(ans, abs(a - b))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(c) for c in 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(b[-1]-b[0])

Submission status: Accepted

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

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

Submission status: Accepted

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

i = 0

abs_lst = []

while (i < n - 1):
	j = i + 1
	while (j < n):
		abs_lst.append(abs(a[i] - a[j]))
		j += 1
 
	i = i + 1
    
print(max(abs_lst))

Submission status: Accepted

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

comb = list(itertools.combinations(A,2))
diff = [abs(i[0]-i[1]) for i in comb]
print(max(diff))

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()]
B=[]
for i in range(N):
    for k in range(i+1,N):
        B.append(abs(A[i]-A[k]))

print(max(B))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    N = input()
    A = list(map(int, input().split()))
    min_a = float("inf")
    max_a = 0
    for a in A:
        min_a = min(min_a, a)
        max_a = max(max_a, a)
    print(max_a - min_a)

if __name__ == "__main__":
    solve()

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

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = 0
    d = 10**9+1 

    for i in range(n):
        c = max(a[i], c)
        d = min(a[i], d)

    print(c-d)

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

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

a.sort()


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
  main()

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

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

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

print(range)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=input().split()
A=[int(i) for i in A]
A.sort(reverse=True)
print(abs(A[len(A)-1]-A[0]))

Submission status: Accepted

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

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

if max(A) > abs(min(A)):
    print(max(A) - min(A))
else:
    print(abs(min(A) - max(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:
a=input()
b=[int(i) for i in input().split()]
print(max(b)-min(b))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np
import math
import re
n = int(input())
a = input()
a = re.split(" ",a)

max = 0
min = 10**9
for i in range(n):
    if(int(a[i]) > max):
        max = int(a[i])
    if(int(a[i]) < min):
        min = int(a[i])
print(max - min)

Submission status: Accepted

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

Submission status: Accepted

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

print(x)

Submission status: Accepted

Solution code:
n = int(input())
mx = 0

a = list(map(int, input().split()))
for i in range(len(a)):
    for j in range(len(a)):
        mx = max(mx,abs(a[i]-a[j]))
print(mx)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    print(result)

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input()
.split()))
min = pow(10,9)
#print(min)
max = 1
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())
an = list(map(int,input().split()))
an.sort()
print(an[N-1]-an[0])

Submission status: Accepted

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

ans = -1
for i in range(len(A)):
    for j in range(len(A)):
        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()))
A = sorted(A)
print(A[-1]-A[0])

Submission status: Accepted

Solution code:
import sys

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

print(sorted(a_list)[-1] - sorted(a_list)[0])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
m=0
for i in range(n-1):
  for j in range(n):
    m=max(abs(a[i]-a[j]),m)
print(m)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i, x in enumerate(a):
    for j, y in enumerate(a):
        if i == j:
            continue
        ans = max(ans, abs(y - x))
print(ans)

Submission status: Accepted

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

maxA = max(a)
minA = min(a)

ans = maxA - minA
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

a.sort()

b = abs(a[N-1]-a[0])

print(b)

Submission status: Accepted

Solution code:
# ABC102B - Maximum Difference
# Better ver.
n = int(input())
lst = sorted(list(map(int, input().rstrip().split())))
print(lst[-1] - lst[0])

Submission status: Accepted

Solution code:
# ABC102B - Maximum Difference
n = int(input())
lst = list(map(int, input().rstrip().split()))
max_dif = 0

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

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

Submission status: Accepted

Solution code:
N = int(input())
Aset = set(map(int, input().split()))

print(max(Aset)-min(Aset))

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    n = input()
    s = input()
    a = [int(i) for i in s.split()]
    mina = min(a)
    maxa = max(a)
    print(maxa - mina)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
num_lists = list(map(int, input().split()))
ans = 0
 
for i in num_lists:
  for j in num_lists:
    diff = abs(i - j)
    if diff > ans:
      ans = diff
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
num_lists = list(map(int, input().split()))
max_num = max(num_lists)
min_num = min(num_lists)
ans = max_num - min_num
print(ans)

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

Submission status: Accepted

Solution code:
count = int(input())
number = map(int,input().split())

n_list= sorted(list(number))

n_count=count-1
answer= n_list[n_count]- n_list[0]

print(answer)

Submission status: Accepted

Solution code:
#coding:UTF-8
num = int(input())
num_list = input()
new = num_list.split(" ")
#print(new)
min=int(new[0])
max=int(new[0])
for i in range(num):
  if min>int(new[i]):
    min=int(new[i])
  if max<int(new[i]):
    max=int(new[i])
print(max-min)

Submission status: Accepted

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

n = int(input())

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

print(max(li) - min(li))

Submission status: Accepted

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


if __name__ == '__main__':
	main()

Submission status: Accepted

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

print(ans)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sort = sorted(nums)
print(abs(sort[-1] - sort[0]))

Submission status: Accepted

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

ans=0
for x in A:
	for y in A:
		ans=max(abs(y-x), ans)

print(ans)

Submission status: Accepted

Solution code:
#102
N=int(input())
A = [int(j) for j in input().split()]
A.sort()
print(abs(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-1):
    for j in range(i, N):
        ans = abs(A[i]-A[j]) if abs(A[i]-A[j]) > ans else ans
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(abs(a[n-1] - a[0]) if len(a) >= 2 else 0)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
A = list(map(int, input().split()))
    
X = 0
for v in itertools.combinations(A, 2):
    if abs(v[0] - v[1]) > X:
        X = abs(v[0] - v[1])
        
print(X)

Submission status: Accepted

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

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

Submission status: Accepted

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

from itertools import combinations

for i, j in combinations(A, 2):
    ans = max(ans, abs(i - j))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/04/11
# AtCoder Beginner Contest 102 - B

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

minval = 10 ** 10
maxval = 0
for i in range(n):
    if a[i] > maxval:
        maxval = a[i]
    if a[i] < minval:
        minval = a[i]

print(abs(maxval - minval))

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

Submission status: Accepted

Solution code:
N = int(input())

A = list(map(int,input().split()))
new_A = sorted(A,reverse=True)
print(new_A[0] - new_A[-1])

Submission status: Accepted

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

print(max(num_list)- min(num_list))

Submission status: Accepted

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

n = int(input())

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

print(max(li) - min(li))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    A.sort()
    print(A[-1]-A[0])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_,a=open(0);*a,=map(int,a.split());print(max(a)-min(a))

Submission status: Accepted

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

max = a[0]
min = a[0]
for i in a:
    if i>max:
        max = i
    if i<min:
        min = i
        
print(max-min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

a = sorted(a)

dmax = a[-1] - a[0]

print(dmax)

Submission status: Accepted

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

x.sort()

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

Submission status: Accepted

Solution code:
s = input()
li = input().split()
li2 = []
for i in li:
    for j in li:
        s = int(i) -int(j) 
        if s >0:
            li2.append(s)
        else:
            li2.append(s * -1)

li2.sort()
ans = li2[-1]
print(ans)

Submission status: Accepted

Solution code:
N = input()
string_list = input().rstrip().split()
l = [int(x) for x in string_list]
_max = 0
_min = l[0]
for t in l:
  if _max < t:
    _max = t
  if _min > t:
    _min = t  
print(_max - _min)

Submission status: Accepted

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

A_max = max(A_list)
A_min = min(A_list)
print(A_max - A_min)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().rstrip().split()))
maximum = A[0]
minimum = A[0]

for i in A:
    if maximum < i:
        maximum = i
    elif minimum > i:
        minimum = i

print(abs(maximum-minimum))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

A_max=max(A_list)
A_min=min(A_list)

print(A_max-A_min)

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:
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
data=sorted(data)
print(abs(data[0]-data[-1]))

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

Submission status: Accepted

Solution code:
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):
        diff = abs(A[i]-A[j])
        if diff > ans: ans = diff

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

maxlen = 0

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

print(maxlen)

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = input().split(" ")
B = [int(n) for n in A]
             
m = float("inf")
M = 0
for b in B:
  if b < m:
    m = b
              
  if b > M:
    M = b
             
print(M-m)

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:
N = int(input())
A = list(map(int,input().split()))
min = 1000000000
max = 0
for i, a in enumerate(A):
    if i == 0:
        max = a
        min = a

    if a > max:
        max = a
    elif a < min:
        min = a
print(max - min)

Submission status: Accepted

Solution code:

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

Amin = 10**9 + 1
Amax = 0

for A in As:
    if A < Amin:
        Amin = A
    if A > Amax:
        Amax = A

print(Amax - Amin)

Submission status: Accepted

Solution code:
N = input()
As = sorted(list(map(int,input().strip().split())))

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

Submission status: Accepted

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

Submission status: Accepted

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

absmax = 0

for i, a in enumerate(A):
    for b in A[i+1:]:
        absmax = max(absmax, abs(a-b))

print(absmax)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(M)-min(M))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
n=int(stdin.readline().rstrip())
a_list=[int(x) for x in stdin.readline().rstrip().split()]
a_list.sort()
print(a_list[n-1]-a_list[0])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(len(a)):
    for j in range(len(a)):
        if i == j:
            continue
        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())
l = list(map(int, input().split()))
l.sort()
print(abs(int(l[0]) - int(l[-1])))

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

Submission status: Accepted

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys


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

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

Submission status: Accepted

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

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

Submission status: Accepted

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