#C10669. Consecutive Subsequence Check

    ID: 39899 Type: Default 1000ms 256MiB

Consecutive Subsequence Check

Consecutive Subsequence Check

You are given a list of n integers. Your task is to determine whether the set of distinct integers in the list forms a contiguous sequence when sorted in increasing order. In other words, after removing duplicates and sorting, every adjacent pair of numbers must differ by exactly 1.

Note: A list with a single element is vacuously considered a contiguous sequence.

Input Example:
7
1 3 2 1 2 3 4

inputFormat

The first line contains an integer n representing the number of elements in the list.
The second line contains n space-separated integers.

outputFormat

Output a single line containing either YES if the distinct integers form a contiguous sequence (each adjacent pair differs by 1) or NO otherwise.

## sample
7
1 3 2 1 2 3 4
YES