#K92012. Festival Harmony
Festival Harmony
Festival Harmony
In the annual village festival, villagers perform using two types of instruments: string instruments (denoted by 0) and percussion instruments (denoted by 1). The festival is considered HARMONIOUS if the number of villagers playing string instruments is an exact multiple of those playing percussion instruments. More formally, if we denote:
- s as the number of string instrument players, and
- p as the number of percussion instrument players,
then the festival is harmonious if either p = 0 or $$s \mod p = 0$$. Otherwise, it is NOT HARMONIOUS.
You are given the number of villagers and a list representing the instrument each villager plays. Your task is to determine whether the festival is HARMONIOUS or NOT HARMONIOUS.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains a single integer
N
, representing the number of villagers. - The second line contains
N
space-separated integers, each being either0
or1
, where0
denotes a villager playing a string instrument and1
denotes one playing a percussion instrument. IfN
is0
, the second line may be omitted.
outputFormat
Output a single line to standard output (stdout) containing either HARMONIOUS
or NOT HARMONIOUS
based on the condition described.
3
0 0 1
HARMONIOUS
</p>