#K54247. Buildings with Sunlight

    ID: 29711 Type: Default 1000ms 256MiB

Buildings with Sunlight

Buildings with Sunlight

You are given \( n \) buildings in a row where each building \( i \) has a height \( h_i \). A building receives sunlight if its height is strictly greater than all the buildings to its left. Formally, the building at index \( i \) receives sunlight if \( h_i > \max\{h_0, h_1, \dots, h_{i-1}\} \) (with the first building always receiving sunlight).

Your task is to compute the number of buildings that receive sunlight.

inputFormat

The input is given via standard input (stdin). The first line contains an integer ( n ) representing the number of buildings. The second line contains ( n ) space-separated integers denoting the heights of the buildings. If ( n = 0 ), the second line is omitted.

outputFormat

Output, via standard output (stdout), a single integer representing the number of buildings that receive sunlight.## sample

6
3 2 4 5 1 7
4