Interval covering

Given several real numbers x1,,xnx_1, \ldots, x_n, we want to find the smallest possible set of closed intervals of length 1 that cover those real numbers. In other words, we must find a set of intervals {[y1,y1+1],,[ym,ym+1]}\{[y_1, y_1 + 1], \dots, [y_m, y_m + 1]\} such that

For instance, if the xix_i’s are 1.4,1.9,2.31.4, 1.9, 2.3 i 2.72.7, a possible solution is {[1.2,2.2],[1.8,2.8]}\{[1.2, 2.2], [1.8, 2.8]\}, because every xix_i is inside of (at least) one of the two intervals, and it is not possible to cover the four real numbers with only one interval.

Input

Input consists of several cases, each with a number nn followed by nn different real numbers. Assume n105n \le 10^5.

Output

For every case, print the minimum number of closed intervals of length 1 that cover the given real numbers.

Problem information

Author: Unknown
Translator: Amalia Duch

Generation: 2026-01-25T10:35:14.480Z

© Jutge.org, 2006–2026.
https://jutge.org