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.

Solution (Python):
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")

























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

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

li.sort()

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

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

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

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

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

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

Solution (Python):
n=int(input())

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



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

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

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

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

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

ans = amax-amin
print(ans)

Solution (Python):
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)

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

Solution (Python):
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))))

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

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

Solution (Python):

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


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

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

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

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

Solution (Python):


n = int(input())

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline

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

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

Solution (Python):
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))

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

Solution (Python):
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()

Solution (Python):


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

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

print(maximum - minimum)

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

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

print(start - end)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):


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

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

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

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

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

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

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

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

Solution (Python):
_ = input()
A = list(map(int, input().split()))

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

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

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

Solution (Python):

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

l.sort()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

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

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

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

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

Solution (Python):


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

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

Solution (Python):

import copy
import random
import bisect 
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])

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

Solution (Python):

_ = int(input())
lst = list(map(int, input().rstrip().split()))
print(max(lst) - min(lst))

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

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

Solution (Python):
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)

Solution (Python):
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()

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

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

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

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

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

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

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

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

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

Solution (Python):
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()

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

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

a.sort()
ans = a[-1] - a[0]

print(ans)

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

a.sort()

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

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

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

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

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

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

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

print(x-y)

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

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

Solution (Python):

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    INF = float("inf")
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
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])

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

Solution (Python):
N = int(input())

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

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

Solution (Python):
n = int(input());hou = list(map(int, input().split()))
print(max(hou)-min(hou))

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

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

Solution (Python):
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)

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

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

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

Solution (Python):
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)

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

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

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

Solution (Python):
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)

Solution (Python):
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())

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

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

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

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

a.sort()

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

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

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

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

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

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

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

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

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

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

Solution (Python):


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

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

Solution (Python):


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

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

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

Solution (Python):

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


"""
r,g,b = LI()
if (g*10+b)%4 == 0:
    print("YES")
else:
    print("NO")
"""

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

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


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

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

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

Solution (Python):
n=int(input())

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

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

Solution (Python):
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)

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

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

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

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

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

Solution (Python):


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)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

Solution (Python):



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


if __name__ == '__main__':
    main()

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

Solution (Python):
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)

Solution (Python):
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)

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
an= sorted(set([int(n) for n in input().split()]))
print(an[-1]-an[0])

Solution (Python):
N = int(input())
a_s = [ int(x) for x in input().split() ]

ans = max(a_s) - min(a_s)

print(ans)

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


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

Solution (Python):
""" AtCoder """

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

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

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

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

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

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

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

Solution (Python):

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


n = ip()                              



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







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

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

Solution (Python):
n = int(input())
x = sorted(list(map(int, input().split())))

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

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

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

Solution (Python):
n = int(input())
aa = sorted(list(map(int, input().split())))

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

Solution (Python):
n = int(input())
aa = list(map(int, input().split()))
ans = max(aa) - min(aa)

print(ans)

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

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

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

Solution (Python):
N = int(input())
A = sorted(list(map(int,input().split())))
dis = 0
for i in range(N-1):
  dis += abs(A[i] - A[i+1])
print(dis)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
def func():
    pass


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

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


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
A = [int(a) for a in input().split()]
A .sort()
B = [i-j for i,j in zip(A[1:],A[:-1])]
print(sum(B))

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

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

Solution (Python):
n = int(input())
house = list(map(int, input().split()))

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

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

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

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

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

Solution (Python):

def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]

n = getInt()
a = getIntList()
a.sort()
print(a[n-1]-a[0])

Solution (Python):
n = int(input())
line = input().split(" ")
a = []

for i in range(n):
    a.append(int(line[i]))

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

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

Amax = max(A)
Amin = min(A)
print(Amax - Amin)

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

Solution (Python):
n = int(input())
a = sorted(list(int(i) for i in input().split()))
print(max(a)-min(a))

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

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

Solution (Python):
if __name__ == '__main__':

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

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

Solution (Python):
input()
l=sorted(set(map(int,input().split())))
print(max(l)-min(l))

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

Solution (Python):
N = int(input())
a = list(map(int,input().split())) 
A = set(a)
B = sorted(A)
C = []
for i in range(len(A)-1):
    C.append(B[i+1]-B[i])
print(sum(C))

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]

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

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

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

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

Solution (Python):
n = input()
print(max([max(a) - min(a) for a in [list(map(int, input().split()))]]))

Solution (Python):
int_n = int(input())
ar_int_a = list(map(int, input().split()))
print(max(ar_int_a) - min(ar_int_a))

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

Solution (Python):
a = int(input())
A = map(int, input().split())
B = []
for i in A:
    B.append(i)
print(max(B) - min(B))

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


abc064_b()