#C2796. Building Blockage Checker

    ID: 46151 Type: Default 1000ms 256MiB

Building Blockage Checker

Building Blockage Checker

Given a sequence of building heights, determine whether any building blocks the view of the building immediately to its right. A building is said to block the view if its height is greater than or equal to the next building's height.

Formally, let \(a_1, a_2, \dots, a_n\) denote the heights of the buildings. You need to check if there exists an index \(i\) (\(1 \le i < n\)) such that \(a_i \geq a_{i+1}\). If such an index exists, print YES; otherwise, print NO.

Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line contains a single integer (n) ((1 \le n \le 10^5)), the number of buildings. The second line contains (n) space-separated integers (a_1, a_2, \dots, a_n), representing the heights of the buildings.

outputFormat

Output a single line containing YES if there exists an index (i) such that (a_i \ge a_{i+1}). Otherwise, output NO.## sample

5
3 1 4 2 5
YES