There was an electronic store heist last night.

All keyboards which were in the store yesterday were numbered in ascending order from some integer number $x$. For example, if $x = 4$ and there were $3$ keyboards in the store, then the devices had indices $4$, $5$ and $6$, and if $x = 10$ and there were $7$ of them then the keyboards had indices $10$, $11$, $12$, $13$, $14$, $15$ and $16$.

After the heist, only $n$ keyboards remain, and they have indices $a_1, a_2, \dots, a_n$. Calculate the minimum possible number of keyboards that have been stolen. The staff remember neither $x$ nor the number of keyboards in the store before the heist.


-----Input-----

The first line contains single integer $n$ $(1 \le n \le 1\,000)$ — the number of  keyboards in the store that remained after the heist.

The second line contains $n$ distinct integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 10^{9})$ — the indices of the remaining keyboards. The integers $a_i$ are given in arbitrary order and are pairwise distinct.


-----Output-----

Print the minimum possible number of keyboards that have been stolen if the staff remember neither $x$ nor the number of keyboards in the store before the heist.


-----Examples-----
Input
4
10 13 12 8

Output
2

Input
5
7 5 6 4 8

Output
0



-----Note-----

In the first example, if $x=8$ then minimum number of stolen keyboards is equal to $2$. The keyboards with indices $9$ and $11$ were stolen during the heist.

In the second example, if $x=4$ then nothing was stolen during the heist.

Difficulty: interview

Starter code:

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

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

print(ans)




n = int(input())
l = list(map(int, input().split()))
mn = min(l)
mx = max(l)
print(mx - mn + 1- n)


from sys import stdin, stdout


n = int(stdin.readline())
vl = list(map(int, stdin.readline().split()))
stdout.write(str(max(vl) - min(vl) + 1 - n))

n = int(input())
l = list(map(int, input().split()))
print(max(l) - min(l) + 1 - len(l))


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

n = int(input())

lst = [int(x) for x in input().split()]

lst.sort()

print(lst[n - 1] - lst[0] - n + 1)




#codeforces_1041A_live
gi = lambda : list(map(int,input().split()))
n, = gi()
l = gi()
print(max(l)-min(l)+1-len(l))

N = int(input())
L = list(map(int,input().rsplit()))
print(max(L)-min(L)-N+1)

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

n = int(input())
arr = list(map(int, input().split()))
mi, ma = min(arr), max(arr)

print((ma - mi + 1) - n)

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

n = input()
a = list(map(int, input().split()))
x1 = min(a)
x2 = max(a)
l = x2 - x1 + 1
print(l - len(a))

#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    a=list(map(int,sys.stdin.readline().split(' ')))
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    print(max(a)-min(a)+1-n)
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

print(mx - mn + 1 - n)

n = int(input())

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

u, v = min(a), max(a)

print(v - u + 1 - n)



from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque
from collections import Counter


def read():
    return int(input())


def readmap():
    return map(int, input().split())


def readlist():
    return list(map(int, input().split()))


N = read()
A = readlist()

A.sort()

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

n=int(input())
l=list(map(int,input().strip().split()))
m=max(l)
n1=min(l)
f=(m-n1)+1
print (f-n)

USE_STDIO = False

if not USE_STDIO:
    try: import mypc
    except: pass

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

def __starting_point():
    main()




__starting_point()

def __starting_point():
    n = int(input())
    a = list(map(int, input().split()))
    mn, mx = min(a), max(a)
    print(mx - mn + 1 - n)

__starting_point()

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

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

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

print(data[-1] - data[0] + 1 - n)


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


from sys import stdin,stdout,exit
def sin(): 
	return stdin.readline().rstrip()
def listInput():
	return list(map(int,sin().split()))
def printBS(li):
	if not li: return
	for i in range(len(li)-1):
		stdout.write("%d "%(li[i]))
	stdout.write("%d\n"%(li[-1]))

n = int(sin())
li = listInput()

print(max(li)-min(li)+1-n)