Triples

Report a typo

Write a program that reads a list of integers and outputs the number of triples in the list.

A triple is three consecutive integers in ascending order — 3,4,5 is a triple, but 5,4,3 and 2,4,6 are not.

The first line contains the size of the list.
The rest of the lines contain the elements of the list.

Output a single integer value that represents the number of triples in the list.

In the example below, there are two triples: 4,5,6 and 5,6,7.

Sample Input 1:

6
1
2
4
5
6
7

Sample Output 1:

2
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic