#CCBCHBAHAI0000065. Kiểm tra mảng không giảm (Check a Nondecreasing Array)

Kiểm tra mảng không giảm (Check a Nondecreasing Array)

Check a Nondecreasing Array (Kiểm tra mảng không giảm)

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}, the array is nondecreasing if

ai−1≤aifor every 1≤i<n.a_{i-1}\le a_i\qquad\text{for every }1\le i<n.

Equal adjacent values are allowed. Determine whether the array satisfies this condition without sorting it.

Input

The first line contains nn. The second line contains nn integers aia_i.

Output

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

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10, ∣ai∣≤103|a_i|\le10^3.

Subtask 2 (30 points): 1≤n≤50001\le n\le5000, ∣ai∣≤106|a_i|\le10^6.

Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le2\cdot10^5, ∣ai∣≤109|a_i|\le10^9.

Example

Input

6
-3 -3 0 4 4 10

Output

YES

Explanation

The sample follows the mathematical definition above.