#K10741. Magic Extractable Stones
Magic Extractable Stones
Magic Extractable Stones
A wizard has a collection of magical stones arranged in a sequence. Each stone has an associated magical number. The wizard can extract magic from a stone if its magical number is not less than all the stones before it. Formally, given a sequence \(S = [s_1, s_2, \dots, s_n]\), the stone at position \(i\) is extractable if \(s_i \geq \max(s_1, s_2, \dots, s_{i-1})\). Note that the first stone is always extractable.
Your task is to count the number of stones from which magic can be extracted.
inputFormat
The input is read from STDIN and consists of two lines:
- The first line contains a single integer \(n\) \((1 \leq n \leq 10^5)\), representing the number of stones.
- The second line contains \(n\) space-separated integers, where the \(i\)-th integer represents the magical number on the \(i\)-th stone.
outputFormat
Output to STDOUT a single integer representing the total number of extractable stones.
## sample5
2 4 1 5 3
3