#C5429. Check Sorted Sequence
Check Sorted Sequence
Check Sorted Sequence
Given a sequence of integers \(a_1, a_2, \ldots, a_n\), determine whether the sequence is sorted in non-decreasing order. In other words, check if \(a_i \leq a_{i+1}\) for all valid indices \(i\). If the sequence is sorted, output YES
; otherwise, output NO
.
inputFormat
The input is given via standard input (stdin). The first line contains an integer (n) ((0 \le n \le 10^5)) representing the number of elements. The second line contains (n) space-separated integers.
outputFormat
Output a single line via standard output (stdout) with the string YES
if the sequence is sorted in non-decreasing order, otherwise output NO
.## sample
5
1 2 2 4 5
YES