16. Elements Greater Than All Previous

Difficulty: easy · Array

Problem

Given an integer array `Arr` of size `N`, count the elements whose value is strictly greater than every element before them. The first element always counts. For example, in `[7, 4, 8, 2, 9]` the elements 7 (first), 8 and 9 qualify, so the answer is 3.

Input

- Line 1: the integer `N`. - Line 2: `N` space-separated integers.

Output

Print the count.

Example 1

Input:
5
7 4 8 2 9
Output:
3

Explanation: 7 is first; 8 beats 7; 9 beats 8. 4 and 2 are smaller than an earlier element, so the count is 3.

Example 2

Input:
5
3 4 5 8 9
Output:
5

Explanation: The array is strictly increasing, so all 5 elements qualify.

Constraints

- 1 <= N <= 10^5 - 1 <= Arr[i] <= 10^9

Solutions are judged against 2 sample and 9 hidden tests. Sign in to solve it · All problems