Shoplifting
A theft occurred at a computer equipment store during the night.
Previously, all keyboards sold in the store were assigned sequential numbers, starting from a certain natural number x. For instance, if x = 4 and the store sold 3 keyboards, they would be numbered 4, 5, 6. Similarly, if x = 10 and 7 keyboards were sold, their numbers would be 10, 11, 12, 13, 14, 15, 16.
After the theft, there are n keyboards left in the store, with numbers a[1]
, a[2]
, ..., a[n]
. Your task is to determine the minimum number of keyboards that were stolen, given that none of the store employees can recall the starting number x.
Input
The first line contains a single integer n (1 ≤ n ≤ 10^3
) – the number of keyboards that remain.The second line contains n integers a[1]
, a[2]
, ..., a[n]
(a[i]
≤ 10^6
) – the numbers of the remaining keyboards, presented in random order.
Output
Output the minimum number of keyboards that could have been stolen, considering that the starting number x is unknown.