#C11126. Consecutive Sequence Reordering

    ID: 40408 Type: Default 1000ms 256MiB

Consecutive Sequence Reordering

Consecutive Sequence Reordering

You are given an array of integers. Your task is to determine whether the elements of the array can be rearranged to form a consecutive sequence.

A consecutive sequence is defined as a sequence in which, if the numbers are sorted, each adjacent pair differs by \(1\). In other words, if the sorted array is \(a, a+1, a+2, \dots, a+n-1\), then the answer is True. Note that the array must not contain any duplicates.

inputFormat

The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers denoting the elements of the array.

outputFormat

Output a single line containing either True if the array can be rearranged into a consecutive sequence or False otherwise.

## sample
5
1 2 3 4 5
True