#K36312. Blooming Periods
Blooming Periods
Blooming Periods
Given a series of plant heights over time, we define a blooming period as a contiguous subsequence where each successive element increases by exactly 1. In mathematical terms, a segment [hi, hi+1, ..., hj] (with j \ge i+1) is a blooming period if for every k such that i \le k < j, the condition $$h_{k+1} = h_k+1$$ holds true.
Your task is to determine the number of distinct blooming periods in the input sequence. Note that if no such period exists, the output should be 0.
For example, given the sequence [1, 2, 3, 1, 2, 3, 4, 1, 2], there are 3 blooming periods.
inputFormat
The input consists of two lines:
- The first line contains an integer $$n$$ (\( n \ge 0 \)) denoting the number of elements in the sequence.
- The second line contains $$n$$ space-separated integers representing the plant heights.
outputFormat
Output a single integer which is the number of blooming periods in the sequence.
## sample3
1 2 3
1