#C9704. Pyramidal Sequence Checker
Pyramidal Sequence Checker
Pyramidal Sequence Checker
A sequence of non-negative integers is defined as pyramidal if and only if there exists an index \(k\) (with \(2 \le k \le n-1\)) such that the following conditions hold:
- \(a_1 < a_2 < \cdots < a_k\) (strictly increasing), and
- \(a_k > a_{k+1} > \cdots > a_n\) (strictly decreasing).
Your task is to determine whether a given sequence is pyramidal. Note that the sequence must have at least 3 elements to form a valid pyramid.
inputFormat
The input is given via stdin and consists of two lines:
- The first line contains a single integer \(n\) (the length of the sequence).
- The second line contains \(n\) space-separated non-negative integers.
outputFormat
Output a single line to stdout with the word "YES" if the sequence forms a pyramidal sequence according to the definition, otherwise output "NO".
## sample7
1 2 3 4 3 2 1
YES