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, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

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

Submission status: Accepted

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

max_num = max(b)
min_num = min(b)

print(max_num - min_num)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def examB():
    N = I()
    A = LI()
    ans = max(A)-min(A)
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    As = sorted(A)
    print(As[-1] - As[0])

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    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(" ")))
As=sorted(A)
print(As[N-1]-As[0])

Submission status: Accepted

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

max = a[0]
min = a[0]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

# res = max([abs(x - y) for x, y in itertools.combinations(An, 2)])
mn = An[0]
mx = An[0]
for i in An:
    if mn > i:
        mn = i
    if mx < i:
        mx = i

print(mx - mn)

Submission status: Accepted

Solution code:
import itertools
N = int(input())

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

res = max([abs(x - y) for x, y in itertools.combinations(An, 2)])

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
length = int(input())
inp = input().split(' ')
A = []
for i in range(0, length):
  A.append(int(inp[i]))
print(max(A) - min(A))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(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()))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

a.sort()

s = a[0]
t = a[len(a)-1]

#print(s)
#print(t)

print(abs(t-s))

Submission status: Accepted

Solution code:

N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a = sorted(a)

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

Submission status: Accepted

Solution code:

count = int(input())
num = input().split()
a = []
for i in num:
    a.append(int(i))

a = sorted(a)

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

Submission status: Accepted

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

print(max(al) - min(al))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n= int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

A1 = sorted(A , reverse =True)

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

Submission status: Accepted

Solution code:
N = int(input())
As = [int(A) for A in input().split()]
max_As = 0
min_As = 10e9
for A in As:
    if A > max_As:
        max_As = A
    if A < min_As:
        min_As = A
print(max_As - min_As)

Submission status: Accepted

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

ans = 0
for i, num in enumerate(A_list):
  for j, n in enumerate(A_list):
    if i == j:
      continue
    s = abs(A_list[i] - A_list[j])
    if s > ans:
      ans = s
print(ans)

Submission status: Accepted

Solution code:
# ABC 102: B – Maximum Difference
n = int(input())
a = [int(s) for s in input().split()]

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

main()

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

Submission status: Accepted

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

print(max(numbers)-min(numbers))

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
Alist = list(map(int, input().split()))
max_num = 0
for A in Alist:
    for A_ in Alist:
        sbn = abs(A - A_)
        max_num = sbn if sbn > max_num else max_num
print(max_num)

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 14:51:29(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, *a = (int(x) for x in sys.stdin.read().split())
    a.sort()
    print(a[-1] - a[0])


if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

Solution code:
import itertools

n = int(input())
A = list(map(int, input().split()))
ans = -float('inf')
cn = itertools.combinations(A, 2)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = list(map(int, input().split()))
a_abs = [abs(i) for i in a]
print(max(a_abs) - min(a_abs))

Submission status: Accepted

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

Submission status: Accepted

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

min = arry[1]
max = arry[1]


for i in range(len(arry)):
  if arry[i] < min:
    min = arry[i]
  if arry[i] > max:
    max = arry[i]

print (max-min)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = input()
A = [int(a) for a 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(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:
# ABC102 B - Maximum Difference
# 2019/11/1

N, *A = map(int, open(0).read().split())
# print(N, A)

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

max_value=0
for i in range(n-1):
    base_value=a_list[i]
    for j in range(i,n):
        max_value=max(max_value, abs(base_value-a_list[j]))

print(max_value)

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 = list(map(int,input().split()))
a_min=float('inf')
a_max=0
for i in a:
    a_min = min(a_min,i)
    a_max = max(a_max,i)
print(a_max-a_min)

Submission status: Accepted

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

print(max(L)-min(L))

Submission status: Accepted

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

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

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

print(max)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
lis = list(map(int, readline().rstrip().split()))
a = sorted(lis)

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

Submission status: Accepted

Solution code:
#
# abc102 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
1 4 6 3"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
1000000000 1"""
        output = """999999999"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
1 1 1 1 1"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

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

A_sorted = sorted(A) 

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
nums = list(map(int,input().split()))
n_min = nums[0]
n_max = nums[1]
for num in nums[0:] :
  if num < n_min :
    n_min = num
  elif num > n_max:
    n_max = num
print(n_max-n_min)

Submission status: Accepted

Solution code:
N = input()
A_list = input().split()

A_list_int = list(map(int, A_list))

max = max(A_list_int)
min = min(A_list_int)

print(max - min)

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

Submission status: Accepted

Solution code:
N = int(input())
nums = [int(e) for e in input().split()]
ans = 0
for i in nums:
    for k in nums:
        sub = abs(i-k)
        if sub > ans:
            ans = sub
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

max_num = 0
min_num = 10**9+1

for i in l:
    max_num = max(max_num,i)
    min_num = min(min_num,i)
    
print(max_num - min_num)

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:


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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = map(int,read().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

big = max(a)
small = min(a)
print(big-small)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = input()
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())
Data = list(map(int,input().split()))
min1 = min(Data)
max1 = max(Data)
print(abs(max1-min1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#102b
N = int(input()) #<100
A_list = [int(e) for e in input().split()] #1<t<200

abs_of_A_list = [abs(i) for i in A_list]

print(max(abs_of_A_list)-min(abs_of_A_list))

Submission status: Accepted

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

for i in range(len(A)):
    A[i] = int(A[i])

saidai = max(A)
saitei = min(A)

print(saidai-saitei)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(b-c)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline


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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

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

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

Submission status: Accepted

Solution code:
B = int(input())

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

max= max(L)
min = min(L)

print(max - min)

Submission status: Accepted

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

max=max(l)
min=min(l)

print(max-min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [int(_) for _ in input().split()]
ans = 0
for i in range(n):
    for j in range(n):
        tem = abs(l[i] - l[j])
        if ans < tem:
            ans = tem
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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())
S = input().split()
S_i = [int(s) for s in S]
tmp_result = 0

for num_i in S_i:    
    for num_ii in S_i:
        difference = abs(num_i - num_ii)
        if difference > tmp_result:
            tmp_result = difference
    
print(tmp_result)

Submission status: Accepted

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

mx = A[0]
mn = A[0]

for i in range(N):
    if A[i] > mx: mx = A[i]
    if A[i] < mn: mn = A[i]

print(mx - mn)

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    print(max(a) - min(a))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    print(abs(a[0] - a[-1]))


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

Submission status: Accepted

Solution code:
N,*A = map(int,open(0).read().split())
A.sort()
print(abs(A[-1]-A[0]))

Submission status: Accepted

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

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

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

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())
m = 1e9
M = 0
a = list(map(int, input().split()))
for i in range(N):
  m = min(m, a[i])
  M = max(M, a[i])
print(M - m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M = l[i]
    else:
      pass
print(M-m)

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

Submission status: Accepted

Solution code:
n = int(input())
s = input().split()
numbers = [int(i) for i in s]
maxDif = 0
for i in range(n):
  for j in range(i+1,n):
    maxDif = max(maxDif, abs(numbers[i] - numbers[j]))
    
print(maxDif)

Submission status: Accepted

Solution code:
# 入力の受け取り
n = int(input())
list = list(map(int, input().split()))

# 最小値と最大値
a = min(list)
b = max(list)

# 最大の絶対値
print(b - a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
M = a[0]
m = a[0]
for i in range(1, n):
  if a[i] > M:
    M = a[i]
  if a[i] < m:
    m = a[i]
print(int(M - m))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Nは使用しない
N = input()
#A1,A2,……をlistで管理する
A = list(map(int, input().split()))
#最大値から最小値を引く
ans = max(A) - min(A)
#答えの出力
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

s = int(a[0])#max
t = int(a[0])#min

for i in a:
    if s < i:
        s = i
    if t > i:
        t = i
'''
for i in a:
    if t > i:
        t = i
'''

print(s - t)

Submission status: Accepted

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

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

s = int(a[0])#max
t = int(a[0])#min

for i in a:
    if s < i:
        s = i

for i in a:
    if t > i:
        t = i

print(s - t)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC102B - Maximum Difference
def main():
    N, *A = map(int, open(0).read().split())
    ans = max(A) - min(A)
    print(ans)


if __name__ == "__main__":
    main()

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