Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/bir-xil-ishorali-bolak

Longest same-sign segment

Medium 1000 ms 64 MB 60%
Share

$n$ integers are given in a row. Find the length of the longest segment of consecutive numbers that are all positive or all negative ($0$ is neither positive nor negative). If there is no such segment (all numbers are $0$), print $0$.

Numbers coloured by sign; the longest same-sign segment is highlighted

Input

The first line contains a positive integer $n$.
The second line contains $n$ integers.

Output

One integer — the length of the longest segment.

Note

$1 \le n \le 10^{5}$
the numbers are from $-10^{9}$ to $10^{9}$

Examples

Input #1
9
3 -1 -4 -2 5 0 6 7 -8
Output #1
3
Input #2
3
0 0 0
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.