~/algor $ cat problems/bir-xil-ishorali-bolak
Longest same-sign segment
Medium
1000 ms
64 MB
60%
$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$.
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