#K43342. Counting Consecutive Height Pairs

    ID: 27288 Type: Default 1000ms 256MiB

Counting Consecutive Height Pairs

Counting Consecutive Height Pairs

You are given a list of n integers representing the heights of students. Your task is to find the number of consecutive pairs of students such that the heights strictly increase by exactly 1. In other words, count the number of indices \(i\) (with \(1 \leq i < n\)) for which the following condition holds:

\(h_{i+1} - h_i = 1\)

For example, if the list of heights is [1, 2, 3, 4, 5, 6, 7], there are 6 consecutive pairs that meet the condition.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains a single integer \(n\) denoting the number of students.
  • The second line contains \(n\) space-separated integers representing the heights of the students.

outputFormat

Output a single integer on standard output (stdout) that represents the number of consecutive pairs of students where the difference between the second and first student's height is exactly 1.

## sample
7
1 2 3 4 5 6 7
6

</p>