#C2381. Mountain Array Checker

    ID: 45691 Type: Default 1000ms 256MiB

Mountain Array Checker

Mountain Array Checker

You are given an array of integers. Your task is to determine whether the array is a mountain array. An array is considered a mountain array if and only if it has at least 3 elements and there exists an index \( i \) (with \( 0 < i < n-1 \)) such that:

  • \( arr[0] < arr[1] < \cdots < arr[i] \)
  • \( arr[i] > arr[i+1] > \cdots > arr[n-1] \)

Note: The peak element (at index \( i \)) must not be the first or the last element of the array.

inputFormat

The first line contains an integer \( n \) denoting the number of elements in the array. The second line contains \( n \) space-separated integers representing the array elements.

outputFormat

Output a single string: "Yes" if the array forms a mountain, or "No" otherwise.

## sample
2
2 1
No