#C8664. Monotonic Array

    ID: 52671 Type: Default 1000ms 256MiB

Monotonic Array

Monotonic Array

Given an integer array, determine whether the array is monotonic. An array is considered monotonic if it is either entirely non-decreasing or entirely non-increasing. In other words, for an array \(A\) of length \(n\), it satisfies one of the following conditions:

\( \forall\, i \in \{1,2,...,n-1\},\ A_i \le A_{i+1} \) or \( \forall\, i \in \{1,2,...,n-1\},\ A_i \ge A_{i+1} \).

Your task is to write a program that reads the array from standard input and outputs whether the array is monotonic. Note that an empty array is considered monotonic.

inputFormat

The first line of input contains an integer ( n ) representing the number of elements in the array. If ( n > 0 ), the second line contains ( n ) space-separated integers denoting the elements of the array.

outputFormat

Output a single line containing either "True" if the array is monotonic or "False" otherwise.## sample

4
1 2 2 3
True