B. Prefixes and Suffixes
Given a sorted array of n zeros. At each step, you can choose an arbitrary number of the first or last elements of this array, and add one to all selected elements. Is it possible to reach the specified state of the array after some number of such operations?
Input format
The first line contains an integer 1 ≤ n ≤ 100000 — the number of elements in the array.
The second line contains n non-negative integers a1, a2, ..., an separated by spaces, where ai ≤ 10^18 — the desired final elements.
Output format
Print "YES" if such a state is achievable, and "NO" if it is not.
Example
Input
[phone]
Output
YES
Note
The states [phone] can be reached as follows:
add one to the first three elements, resulting in [phone]
add one to the last four elements, resulting in [phone]
add one to the last element, resulting in [phone]