cho.sh
Notes
Loading...

Sequence

Time limit

1s

Memory limit

128 MB

Problem

You are given a sequence of length N made of digits from 0 to 9. Consider contiguous segments that, from left to right, are either nondecreasing or nonincreasing.

Print the maximum possible length of such a segment. Equal adjacent digits satisfy both direction conditions.

Input

The first line contains the length N of the sequence.

The second line contains N digits separated by spaces.

N is an integer between 1 and 100,000, inclusive.

Output

Print the length of the longest contiguous segment that is nondecreasing or nonincreasing.