Is it a Heap?#3737

Is it a Heap?

1 second
128 megabytes
Very easy

The Heap data structure can be implemented using an array.

The array must maintain the main heap property: for each i~(1 \le i \le n) next conditions must hold:

The array of integers is given. Determine whether it is a heap.

Input

First line contains number n~(1 \le n \le 10^5). Second line contains integers that do not exceed 2 \cdot 10^9 by absolute value.

Output

Print "YES", if the array is a heap and "NO" otherwise.

Examples

Example 1

Loading
Loading