#K52337. Check if List is Sorted

    ID: 29287 Type: Default 1000ms 256MiB

Check if List is Sorted

Check if List is Sorted

You are given a list of integers. Your task is to determine whether the list is sorted in non-decreasing order.

A list is considered sorted in non-decreasing order if for every pair of consecutive elements, the previous element is not greater than the next element. An empty list or a list with a single element is considered sorted.

Formally, given a list of integers \(a_1, a_2, \dots, a_n\), you need to check if \(a_i \leq a_{i+1}\) for all valid \(i\).

The input is provided via standard input and the output should be printed to standard output.

inputFormat

The first line contains a single integer \(n\) denoting the number of elements in the list. The second line contains \(n\) space-separated integers. If \(n = 0\), the second line may be empty.

outputFormat

Print True if the list is sorted in non-decreasing order, and False otherwise.

## sample
6
1 2 2 3 4 5
True

</p>