Problem:


Score : 200 points

Problem Statement

It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.

There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.

Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.  

Constraints

1 ≤ N ≤ 100

0 ≤ a_i ≤ 1000

a_i is an integer.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

Print the minimum distance to be traveled.  

Sample Input 1

4
2 3 7 9

Sample Output 1

7

The travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2.

It is not possible to do with a travel distance of less than 7, and thus 7 is the minimum distance to be traveled.  

Sample Input 2

8
3 1 4 1 5 9 2 6

Sample Output 2

8

There may be more than one house at a position.  



Sample input:
4
2 3 7 9


Sample output:
7

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ls = sorted(set(map(int, input().split())))
ans = 0
for i in range(len(ls)-1):
    ans += ls[i+1] - ls[i]
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
data = list(map(int, input().split()))
data.sort()
print(data[-1] - data[0])

Submission status: Accepted

Solution code:
n=int(input())
house=input().split()
print(int(max(house))-int(min(house)))

Submission status: Accepted

Solution code:
import numpy as np

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

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

Submission status: Accepted

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

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

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    _, b, c = LS()
    x = int(b[0] + c[0]) % 4
    if not x:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    n = II()
    a = LI()
    a.sort()
    print(a[-1]-a[0])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

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

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

Submission status: Accepted

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

def main(N, A):
    A = sorted(set(A))
    print(max(A)-min(A))
    
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    
    main(N, A)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

a = list(set(a))
a.sort()
print(sum([a[i+1] - a[i] for i in range(len(a) - 1)]))

Submission status: Accepted

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
ans=max(a)-min(a)
print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n-1):
    ans += a[i+1] - a[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

distinct_A = list(set(A))
distinct_A.sort()

print(sum([distinct_A[i] - distinct_A[i-1] for i in range(1, len(distinct_A))]))

Submission status: Accepted

Solution code:

N = int(input())

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

a.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
ans = 0
for i in range(N-1):
    ans += A[i+1] - A[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

L.sort()
anser = L[input1-1] - L[0]
#print(input1)
#print(L)
print(anser)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
print(max(data) - min(data))

Submission status: Accepted

Solution code:

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
A = nl()

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

Submission status: Accepted

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

a = sorted(a)

for i in range(1,N):
    ans.append(abs(a[i-1] - a[i]))

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
*A, = map(int, input().split())
A = sorted(A)
print(sum([A[i]-A[i-1] for i in range(1, N)]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


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:
house_num = list(map(int, input().split())) #cityの数、roadの数の配列
arr = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる

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

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

Submission status: Accepted

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


abc()

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


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

Submission status: Accepted

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

a.sort()

ans = 0
for i in range(N-1):
    ans += a[i+1] - a[i]
print (ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# S = sys.stdin.readline().rstrip()
# i = 2
# while len(S) - i > 0:
#     l = len(S) - i
#     if S[:l // 2] == S[l // 2:l]:
#         print(l)
#         break
#     i += 2

#
# N = int(sys.stdin.readline())
# A = [int(sys.stdin.readline()) for _ in range(N)]
#
# ans = 0
# i = 0
# for _ in range(N+1):
#     i = A[i]-1
#     ans += 1
#     if i == 1:
#         print(ans)
#         exit()
# print(-1)


N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
print(max(A) - min(A))

Submission status: Accepted

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

li.sort()

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

Submission status: Accepted

Solution code:
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()))
Ma = max(A)
Mi = min(A)
print(Ma-Mi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

#print(nums)

print(max(nums)-min(nums))

Submission status: Accepted

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

Submission status: Accepted

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

amax = max(a)
amin = min(a)

ans = amax-amin
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
sum = 0
for i in range(n-1):
  sum += a[i+1] - a[i]
print(sum)

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 = sorted(list(set(A)))
print(sum(B[i] - B[i - 1] for i in range(1, len(B))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
As = sorted(list(mi()), reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

max = 0
min = 1000

for i in a:
    if i > max:
        max = i
    if i < min:
        min = i

print(str(max - min))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    a = [0] + [int(ele) for ele in input().split()]
    a.sort()
    ans = 0
    for i in range(1,N+1):
        diff = a[i] - a[i-1]
        ans += diff

    tmp = ans
    ans =0
    a.sort(reverse=True)
    for i in range(1,N):
        diff = abs(a[i] - a[i-1])
        ans += diff
    ans = min(ans,tmp)
    print(ans)

       




if __name__=="__main__":
    main()

Submission status: Accepted

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

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

minimum = min(a)
maximum = max(a)

print(maximum - minimum)

Submission status: Accepted

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

start = max(A)
end = min(A)

print(start - end)

Submission status: Accepted

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

Submission status: Accepted

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

print(max(h)-min(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
i =  input().split()
max=int(max(i))
min=int(min(i))
answer=int(max)-int(min)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

    cost = A[N-1] - A[0]
    ans = cost
    for i in range(1, N):
        if i+N-1 >= N:
            break
        cost = A[i+N-1] - A[i]
        ans = min(ans, cost)
    
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

l.sort()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

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

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

Submission status: Accepted

Solution code:
# ABC064B - Traveling AtCoDeer Problem
_ = int(input())
lst = list(map(int, input().rstrip().split()))
print(max(lst) - min(lst))

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 sys
from collections import Counter

n = int(input())
a_list = sorted(list(set(list(map(int, input().split())))))
ans = 0

for i in range(1, len(a_list)):
    ans += a_list[i] - a_list[i-1]

print(ans)

Submission status: Accepted

Solution code:
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist

def submit():
    n, alist = read_input()

    mostleft = max(alist)
    mostright = min(alist)

    print(mostleft - mostright)

if __name__ == '__main__':
    submit()

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()
    a = sorted(a)
    print(a[n-1] - a[0])
    

solve()

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

a.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(x-y)

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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    a.sort()
    ans = 0
    for i in range(1,N):
        if(a[i]!=a[i-1]):
            ans += a[i] - a[i-1]
    print(ans)
    
if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
l=sorted(map(int,input().split()))
print(l[-1]-l[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:
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()
a = nl()

a.sort()

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

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())
ans = 0
zahyou = list(map(int, input().split()))
zahyou.sort(reverse=True)
for i in range(N-1):
    ans += zahyou[i] - zahyou[i + 1]
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())
List=list(map(int,input().split()))
print(sorted(List)[-1]-sorted(List)[0])

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

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:
_,t=open(0);*a,=map(int,t.split());print(max(a)-min(a))

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()

result = 0
for i in range(N-1):
    result += a[i+1] - a[i]
print(result)

Submission status: Accepted

Solution code:
import sys

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

    return max(A) - min(A)


if __name__ == '__main__':
    print(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:
input()
Lists = sorted(map(int,input().split()))
print(Lists[-1] - Lists[0])

Submission status: Accepted

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

Submission status: Accepted

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

print(max(hoge)-min(hoge))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
r,g,b = LI()
if (g*10+b)%4 == 0:
    print("YES")
else:
    print("NO")
"""
#B
n = I()
a = LI()
print(max(a)-min(a))
#C
"""
f = [0]
for i in range(1,400):
    f.append(0)
for i in range(400,800):
    f.append(1)
for i in range(800,1200):
    f.append(2)
for i in range(1200,1600):
    f.append(3)
for i in range(1600,2000):
    f.append(4)
for i in range(2000,2400):
    f.append(5)
for i in range(2400,2800):
    f.append(6)
for i in range(2800,3200):
    f.append(7)
for i in range(3200,4801):
    f.append(-1)
n = I()
a = LI()
k = [1 for i in range(8)]
s = 0
t = 0
for i in a:
    if f[i] >= 0:
        if k[f[i]]:
            k[f[i]] = 0
            s += 1
    else:
        t += 1
print(max(s,1),min(s+t,n))
"""

#D
"""
n = I()
s = S()
ans = []
k = 0
for i in range(n):
    if s[i] == ")":
        k += 1
    else:
        if k > 0:
            ans += ["("]*k
            k = 0
        k -= 1
if k < 0:
    ans += [")"]*(-k)
else:
    ans = ["("]*k+ans
i = 0
if len(ans) == 0:
    for i in s:
        print(i,end = "")
else:
    while ans[i] == "(":
        i += 1
        if i == len(ans):break
    for j in range(n):
        ans.insert(i+j,s[j])
    for i in ans:
        print(i,end = "")
print()
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

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

Submission status: Accepted

Solution code:
def traveling_atcodeer_problem(N: int, A: list)->int:
    return max(A) - min(A)


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = traveling_atcodeer_problem(N, A)
    print(ans)

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

Submission status: Accepted

Solution code:
# 064 B

N = int(input())
A=[int(j) for j in input().split()]
A =list(set(A))
A.sort(reverse=True)
ans = 0
for i,j in enumerate(A):
    if i !=len(A)-1:
        ans += A[i] - A[i+1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
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:
# -*- coding: utf-8 -*-


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
count = 0
for i in range(len(a)-1):
    count += int(a[0]) - int(a[1])
    a.pop(0)
print(count)

Submission status: Accepted

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

Submission status: Accepted

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