Equal Treasure

Easy

1s time · 256MB memory · arrays

Two treasure chests stand at the ends of a long corridor, each labelled with a number — and so is every chest between them. Legend says the corridor hides equal treasure only when the two end chests carry the same label.

If the first and last elements of the array are equal, print YES; otherwise print NO.

Input

The first line contains one integer n.

The second line contains n integers a₁ … aₙ.

Output

Print YES or NO.

Constraints

  • 1 ≤ n ≤ 2·10⁴
  • −10⁷ ≤ aᵢ ≤ 10⁷
  • When n = 1, the first and last element are the same element.

Samples

Input 1
6
4 7 2 9 1 4
Output 1
YES
Input 2
3
1 2 3
Output 2
NO
Sign in (top right) to run or submit.