In a kingdom far away,
$N$ people live in a circle of harmony. Literally, they have constructed a circular area and built their houses towards the periphery of it. For simplicity, we can assume that the kingdom is a circle and the houses are points on the circle's periphery.
Due to this scenario, a person living in that kingdom, can only interact with the two other neighbors who are adjacent to that person. When a person needs to make some money transaction, he can only do so with either the person on his right or with the person on his left.
Photo Credit: Hedning
Now, there is a huge economic crisis going on in the kingdom and the king has decided to equally divide the wealth across all the citizens. But the circular city only allows direct transaction between neighbors. Not just that, the king also ordered that a person can make at most one transaction with one of his neighbors.
So here's the deal, given the wealth of
$N$ individuals and their relative positions, can you decide whether it would be possible to divide the money equally among all the people?
The first line of the input will contain an integer
$(1 \leq N \leq 10^5)$, the size of the population of the kingdom. The following
$N$ lines will have one integer
$1\leq x_i \leq 10^9$) , where
$x_i$ is the wealth of the i'th person. Since all the people of this kingdom are living in a circle, we have picked a position at some point of the circle and called it
$N$ are adjacent to each other.
Output one line, Yes if it's possible to distribute the amount equally and No otherwise.
3 1 1 1
Since all of the citizens have equal amount, they already fulfill king's requirements.