#K58057. Mountain Array Validation

    ID: 30557 Type: Default 1000ms 256MiB

Mountain Array Validation

Mountain Array Validation

Given an array of integers, determine whether it forms a mountain array.

An array is considered a mountain array if and only if:

  • It contains at least 3 elements.
  • There exists an index \(i\) where \(0 < i < n-1\) such that:
    • The sequence strictly increases from the beginning up to index \(i\), i.e., \(a_0 < a_1 < \ldots < a_i\).
    • The sequence strictly decreases from index \(i\) to the end, i.e., \(a_i > a_{i+1} > \ldots > a_{n-1}\).

Print true if the array satisfies these conditions; otherwise, print false.

inputFormat

The input is read from standard input (stdin). The first value is an integer \(n\) representing the number of elements in the array, followed by \(n\) integers separated by spaces.

outputFormat

Output a single line to standard output (stdout) containing true if the array is a mountain array or false otherwise.

## sample
7
2 3 4 5 3 2 1
true