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-----
4
2 3 7 9

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

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

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

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

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

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

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

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

N = int(input())
N_List = list(map(int,input().split()))
print(max(N_List)-min(N_List))

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

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

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

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

result = max(points) - min(points)
print(result)

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

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





# B - Traveling AtCoDeer Problem
def main():
    _ = int(input())
    a = list(map(int, input().split()))

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



if __name__ ==  "__main__":
    main()

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

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

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

print(max(x) - min(x))

#https://atcoder.jp/contests/abc064/tasks/abc064_b
S_list = [input() for i in range(2)]
N = map(int,S_list[0].split())    
A_list = list(map(int,S_list[1].split()))

print(max(A_list)-min(A_list))

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

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

distance = 0

for i in range(N - 1):
    distance += a[i + 1] - a[i]

print(distance)

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

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

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

N=int(input())
a=str(input())

def ans064(N:int, a:str):
    a_list=sorted(map(int,a.split()))
    return(a_list[-1]-a_list[0])

print(ans064(N,a))

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

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

print(max(list02) - min(list02))

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


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

max = 0
min = 1000

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

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

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

print(max(arr) - min(arr))

def answer(n: int, a: []) -> int:
    return max(a) - min(a)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(answer(n, a))


def __starting_point():
    main()
__starting_point()

# クリスマスもあと半年となり、トナカイのAtCoDeer君はプレゼントを配る計画を立てることにしました。
# TopCoDeer通りにはN個の家が並んでいます。i個目の家は座標aiにあります。彼はこのすべての家にプレゼントを配ることにしました。
# 好きな場所から開始し好きな場所で終了することができる時、最小の移動距離を求めなさい。

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

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

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

# 一番離れている座標の差
print(max(a) - min(a))

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

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

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

print((max(coordinates) - min((coordinates))))



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

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

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

distance = max(a)-min(a)

print(distance)

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


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

a1=max(a)
a2=min(a)

print((a1-a2))


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

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

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

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

with open(0) as f:
    N, *a = map(int, f.read().split())
print(max(a)-min(a))

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

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

# 064b

def atc_064b(input_value: str) -> str:
    N = input_value[0]
    ai = [int(i) for i in input_value[1].split(" ")]
    return max(ai) - min(ai)

N = input()
ai = input()
print(atc_064b([N, ai]))

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

Number = list(S)
Number.sort(reverse=True)
total_distance = []
# print(Number)

for i in range(1,N):
    distance = Number[0] - Number[1]
    total_distance.append(distance)
    del Number[0]

print(sum(total_distance))

def abc064b(n: int, a_list: int) -> int:
    return max(a_list) - min(a_list)

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

print((abc064b(n, a_list)))


n = int(input())
a = list(map(int,input().split()))
# リストの最大値から最小値を引いて出力
print((max(a)-min(a)))


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

    return ans

print((main()))


home_num = int(input())
house_from = list(map(int,input().split()))

print(max(set(house_from)) - min(set(house_from)))

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

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

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

# 数値の取得
homecnt = int(input())
homeplace = list(map(int,input().split()))

# 最短距離を計算し出力
dist = max(homeplace) - min(homeplace)
print(dist)

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


def atc_064b(input_value: str) -> str:
    N = input_value[0]
    ai = [int(i) for i in input_value[1].split(" ")]
    return max(ai) - min(ai)

N = input()
ai = input()
print((atc_064b([N, ai])))


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

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

print((max(house_list) - min(house_list)))


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

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

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

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

MAX = max(A)
MIN = min(A)

print(MAX-MIN)

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

def answer(n:int, a:list)->int:
    return max(a)-min(a)

print(answer(n,a))

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

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

A.sort()

print(A[-1] - A[0] if N > 1 else 0)

n = int(input())
a = [int(x) for x in input().split()]
print(max(a) - min(a))

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

import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10**9)
INF = float('inf')
MOD = 10**9 + 7
#MOD = 998244353


def si(): return input()
def ii(): return int(input())
def fi(): return float(input())
def lstr(): return input().split()
def lint(): return list(map(int, input().split()))
def lintdec(): return list(map(lambda x:int(x) - 1, input().split()))
def lnstr(n): return [input() for _ in range(n)]
def lnint(n): return [int(input()) for _ in range(n)]
def lint_list(n): return [lint() for _ in range(n)]



############################################################
N = ii()
ma = 0
mi = INF

for a in lint():
    ma = max(ma, a)
    mi = min(mi, a)

print(ma - mi)

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

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

print(max(Ni)-min(Ni))

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

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

print(max(house) - min(house) )

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

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

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

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

distance = 0

for i in range(N - 1):
    distance += a[i + 1] - a[i]

print(distance)

# B - Traveling AtCoDeer Problem

# N
N = int(input())
my_list = list(map(int, input().split(maxsplit=N)))

my_list_sort = sorted(my_list)
answer = my_list_sort[-1] - my_list_sort[0]

print(answer)


N = int(input())
lst = input().split()

for i in range(N):
   lst[i] = int(lst[i])

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

from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N = ri()
    a = ril()
    print((max(a) - min(a)))


def __starting_point():
    main()

__starting_point()

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

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

import sys

input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(A[N-1] - A[0])

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

# プレゼントを届けるための、最大値から最小値を引いて、最小の移動距離を出力

print(max(house)-min(house))

# 最小の移動距離は、一番端から反対側まで一直線に移動する事。
# 行ったり来たりする可能性はない
n = int(input())
a = list(map(int, input().split()))
# 座標は正の整数のみなのでmax-minで計算できそう。
# print(mix-min)
print(max(a)-min(a))

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

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

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


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

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

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

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

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

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

def minimum_dist(l1: list) -> int:
    return max(l1) - min(l1)


def __starting_point():
    n = int(input())
    list_coordinate = list(map(int, input().split()))
    print((minimum_dist(list_coordinate)))

__starting_point()

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

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

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

max_v = max(a)
min_v = min(a)

print((max_v - min_v))


# listを並び替えて移動距離の最小値を求める

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

# 降順に並び替える
descending_a = sorted(a, reverse=True)
# print(descending_a)

# 座標の最大値から最小値を引く→移動距離を求める
print((descending_a[0] - descending_a[-1]))


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

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

n,*a=map(int,open(0).read().split())
a.sort()
print(a[-1]-a[0])

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

N = int(input())
A = list(map(int, input().split()))
x = max(A)
y = min(A)
print(x - y)

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

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

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

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

print((max(home))-(min(home)))

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