The Heap data structure can be implement using an array.
The array must maintain the main heap property: for each i (1≤i≤n) next conditions must hold:
If 2i≤n, then ai≤a2i
If 2i+1≤n, then ai≤a2i+1
The array of integers is given. Determine whether it is a heap.
First line contains number n (1≤n≤105). Second line contains n integers that do not exceed 2⋅109 by absolute value.
Print "YES", if the array is a heap and "NO" otherwise.