#C2487. Harmonious Array Checker
Harmonious Array Checker
Harmonious Array Checker
A harmonious array is defined as an array where the difference between its maximum and minimum elements is exactly \(1\), i.e. \(max - min = 1\). Given an array of integers, your task is to determine if the array is harmonious.
If the array is harmonious, print True
. Otherwise, print False
.
The program should read from standard input (stdin) and output the result to standard output (stdout).
inputFormat
The first line of input contains a single integer \(n\) denoting the number of elements in the array. The second line contains \(n\) space-separated integers representing the elements of the array.
outputFormat
Output a single line containing either True
or False
depending on whether the array is harmonious.
5
1 2 2 2 1
True