Gioconda

Time limit: 1s
Memory limit: 256MB
Input:
Output:

While searching in the garbage cans, Jean found a sequence of NN positive integers. Because he has no use for this, he gifted it to Nicusor Gioconda, and gave him a challenge too.

Nicusor has to chose pairwise distinct substrings of length 22 such that every index is taken at least once. If he will give a correct partitioning, he will get the ultimate prize: the magical chicken wing!

In this problem, we consider that a substring is a contiguous subset of indices [i,i+1,j1,j][i,i+1,\cdots j-1, j].

Because he is far better at singing than he is at solving problems, he asks for your help.

Input data

First line will contain a single number NN (1N1051 \leq N \leq 10^5) - the length of the sequence.
The next line contains a sequence AA of NN positive values (1Ai5001 \leq A_i \leq 500).

Output data

The first line will contain a string that is either YES or NO, that represents the existence of a correct partitioning.

Constraints and clarifications

  • For 2020 point it is guaranteed that N20N \leq 20;
  • For the other 8080 points we have N105N \leq 10^5.

Example 1

stdin

5
1 2 1 2 3

stdout

YES

Explanation

For the first example, a valid partitioning is [1,2],[2,1],[2,3][1,2], [2,1], [2,3] corresponding to the indices [1,2],[2,3],[4,5][1,2], [2,3], [4,5].

Example 2

stdin

5
1 2 2 2 2

stdout

NO

Log in or sign up to be able to send submissions!