Practice on Toph

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

Find the Good Sequence

By Key_logger · Limits 1s, 512 MB

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.

Input

The first line contains single positive integer n (1 <= n <= 106) — the number of integers.
Then each of the next ith line contains ith element of the array. (0 <= array element <= 107 )

Output

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

Sample

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

Discussion

Statistics


83% Solution Ratio

TahseenEarliest, 4w ago

RamprosadGFastest, 0.1s

SAIF_IITLightest, 11 MB

mdvirusShortest, 217B

Submit

Login to submit

Related Contests

NSTU ICE Fest Regional Programming Contest 2020 Ended at 2020-01-24 07:15:00 +0000 UTC
Mirror of NSTU ICE Fest Regional Programming Contest 2020 Ended at 2020-01-24 08:15:00 +0000 UTC