#C9741. Maximum View Distance

    ID: 53868 Type: Default 1000ms 256MiB

Maximum View Distance

Maximum View Distance

Given a sequence of building heights, your task is to determine the maximum view distance. For each building at index (i), the view distance is defined as the smallest (j - i) such that (\text{heights}[j] > \text{heights}[i]) for (j > i). If there is no taller building after (i), the view distance is (n - i - 1), where (n) is the number of buildings. Finally, you should output the maximum view distance among all buildings.

You are to solve this problem by reading input from standard input (stdin) and writing the result to standard output (stdout).

inputFormat

The first line contains an integer (n) (the number of buildings). The second line contains (n) space-separated integers representing the heights of the buildings. Each height is between 0 and 100000.

outputFormat

Output a single integer representing the maximum view distance as defined above.## sample

6
3 7 8 3 6 1
3

</p>