#K78227. One Change to Equality

    ID: 35040 Type: Default 1000ms 256MiB

One Change to Equality

One Change to Equality

Given an array of \(N\) integers, determine whether it is possible to make all elements equal by modifying at most one element. Formally, given an array \(a_1, a_2, \ldots, a_N\), you are allowed to change at most one of its elements. The task is to check if after at most one modification, all elements in the array can become the same.

Example: For the array [1, 1, 1, 2, 1], by changing the element 2 to 1, all elements become equal, so the answer is "YES".

inputFormat

The input is read from standard input (stdin). The first line contains an integer \(N\) (\(1 \leq N \leq 10^5\)), the number of elements in the array. The second line contains \(N\) space-separated integers representing the array elements.

outputFormat

Output a single line to standard output (stdout): print "YES" if it is possible to make all elements equal by modifying at most one element, otherwise print "NO".

## sample
5
1 1 1 2 1
YES

</p>