#C4855. Mountain Sequence

    ID: 48439 Type: Default 1000ms 256MiB

Mountain Sequence

Mountain Sequence

You are given an array of integers. Your task is to determine whether the array forms a mountain sequence.

A valid mountain sequence must satisfy the following conditions:

  • The array length is at least 3.
  • There exists an index \( i \) (1 \( \leq i \leq n-2 \)) such that:
    • The subarray \( a_0, a_1, \dots, a_i \) is strictly increasing.
    • The subarray \( a_i, a_{i+1}, \dots, a_{n-1} \) is strictly decreasing.
  • The peak cannot be the first or the last element.

Input is read from standard input and the result must be printed to standard output as either True or False.

inputFormat

The first line contains a single integer \( n \) which denotes the number of elements in the array. The second line contains \( n \) space-separated integers representing the array elements.

outputFormat

Output a single line: True if the array forms a mountain sequence, otherwise False.

## sample
5
2 5 7 3 1
True