Monotonic Array


Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Determine whether an array is monotonic: entirely non-decreasing or entirely non-increasing.

Input

The first line contains \(n\). The second line contains \(n\) integers.

The input satisfies:

  • \(1 <= n <= 10^5\)

Output

Print YES if the array is monotonic; otherwise print NO.

Example

Input
4
5 3 1 -4
Output
YES

Comments

There are no comments at the moment.