# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Let’s say two numbers are called “**good**” if their difference is at least 2.

Similarly, a sequence is also called good if the sequence is increasing and each adjacent two elements in this sequence are good as well. A sequence must **consist of at least 2 elements**.

Given an array of length **n**, For each index **i** (1 <= i <= n), print the **maximum length of a consecutive good sequence** starting from position **i**.

The first line contains single positive integer n (1 <= n <= 10^{6}) — the number of integers.

Then each of the next i^{th} line contains i^{th} element of the array. (0 <= array element <= 10^{7 })

For each index **i** (1 <= i <= n), print the maximum length of a consecutive good sequence starting from position **i**.

Input | Output |
---|---|

7 1 3 5 6 8 10 11 | 3 2 0 3 2 0 0 |

83% Solution Ratio

TahseenEarliest,

RamprosadGFastest, 0.1s

SAIF_IITLightest, 11 MB

mdvirusShortest, 217B

Login to submit