#K94327. Swapping Adjacent Sequence Checker

    ID: 38617 Type: Default 1000ms 256MiB

Swapping Adjacent Sequence Checker

Swapping Adjacent Sequence Checker

You are given a sequence of n integers. A sequence is called a Swapping Adjacent Sequence (SAS) if for every i with \(2 \le i \le n\), the condition \(a_i \le a_{i-1}\) holds, where \(a_i\) denotes the \(i\)-th element of the sequence.

Your task is to determine whether the given sequence satisfies this non-increasing property. In other words, check if the sequence is sorted in non-increasing order (allowing equal adjacent values).

Input/Output Format: The input is read from stdin and the output should be printed to stdout. See the input and output description sections for details.

Formula:

\[ a_i \le a_{i-1}, \quad \text{for all } i = 2,3,\dots,n. \]

inputFormat

The first line contains a single integer n (\(1 \le n \le 10^5\)), representing the length of the sequence. The second line contains n space-separated integers, denoting the elements of the sequence.

outputFormat

Output a single line containing YES if the sequence is a Swapping Adjacent Sequence (i.e. non-increasing), or NO otherwise.

## sample
5
5 4 3 2 1
YES

</p>