#C7358. Longest Contiguous Ascending Subarray Length

    ID: 51220 Type: Default 1000ms 256MiB

Longest Contiguous Ascending Subarray Length

Longest Contiguous Ascending Subarray Length

Given an array of integers, find the length of the longest contiguous subarray where each element is exactly 1 greater than its previous element. In other words, find the maximum length (L) such that for some index (i), the condition (a_{i+j} = a_i + j) holds for all (0 \le j < L). Note that for an empty array, the answer is 0, and for a non-empty array, each individual element counts as a subarray of length 1.

inputFormat

The input is read from standard input. The first line contains a non-negative integer (n) which represents the number of elements in the array. If (n > 0), the next line contains (n) space-separated integers.

outputFormat

Output a single integer to standard output: the length of the longest contiguous subarray in which each element is exactly 1 greater than the previous element.## sample

0
0

</p>