Loading [MathJax]/jax/output/CommonHTML/jax.js
Bitonic sequence - MarisaOJ: Marisa Online Judge

Bitonic sequence

Time limit: 1000 ms
Memory limit: 256 MB

Given an array A consisting of n integer elements, check if A is a bitonic sequence.

A sequence is called a bitonic sequence if there exists an index i such that:

  • For all j<i, Aj<Aj+1.
  • For all j>i, Aj<Aj−1.

Input

  • The first line contains an integer n.
  • The second line contains n integers Ai.

Output

  • If A is a bitonic sequence, print YES, otherwise print NO.

Constraints

  • 1≤n≤105.
  • 1≤Ai≤109.

Example

Input:

4
1 4 10 2

Output:

YES