By swapping we can adjust array only when the frequency of the element which occurs most is less than or equal to ( n + 1 ) / 2 .
if mx > ( n + 1 ) // 2 : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT