#K7066. Special Sequence Checker

    ID: 33358 Type: Default 1000ms 256MiB

Special Sequence Checker

Special Sequence Checker

You are given a sequence of n integers. A sequence is called a Special Sequence if it satisfies the following conditions:

  • The sequence is strictly increasing, i.e. \(a_1 < a_2 < \cdots < a_n\).
  • The sequence can be partitioned into exactly two non-empty subsequences such that one of them contains only even numbers and the other contains only odd numbers. In other words, there must be at least one even number and at least one odd number in the sequence.

Your task is to determine whether a given sequence is a Special Sequence.

inputFormat

The input is given via standard input and consists of two lines:

  1. The first line contains a single integer \(n\) (\(1 \le n \le 10^5\)) representing the number of elements in the sequence.
  2. The second line contains \(n\) integers separated by spaces, representing the elements of the sequence.

outputFormat

Print a single line to standard output: "YES" if the sequence is a Special Sequence, or "NO" otherwise.

## sample
5
1 2 3 4 5
YES