#K45977. Successful Hike

    ID: 27873 Type: Default 1000ms 256MiB

Successful Hike

Successful Hike

You are given a hike described by a sequence of elevation points. The hike is considered successful if and only if the elevation sequence first strictly increases and then strictly decreases. Formally, there exists an index \(i\) (with \(1 < i < n\)) such that:

\(a_1 < a_2 < \dots a_{i+1} > \dots > a_n\).

Note that any flat segment (where consecutive points are equal) is not allowed. Additionally, the hike must have at least 3 points in order to form a peak.

inputFormat

The first line contains an integer \(n\) representing the number of elevation points. The second line contains \(n\) space-separated integers representing the elevation points.

outputFormat

Output a single line containing YES if the hike is successful, and NO otherwise.

Make sure your solution reads from standard input and writes to standard output.

## sample
5
1 3 5 4 2
YES