logo AlgoBeat OnlineJudge
登录 注册

#215760. [2018 KAIST RUN Spring] Zigzag

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A sequence is called “Zigzag” if no three of its consecutive elements are monotone.

More formally, if sequence of length is Zigzag if, for all (), neither nor holds.

For given sequence of length , you should find a longest subsegment of which is a Zigzag sequence. Sequence of length is subsegment of sequence of length if, for some , , , holds.

输入格式

Input consists of two lines.

The first line contains integer , length of sequence .

The second line contains space-separated integers. th number is .

输出格式

Print out the length of longest subsegment of which is a Zigzag sequence.

样例

样例输入 1

3
1 2 3

样例输出 1

2

样例输入 2

5
1 3 4 2 5

样例输出 2

4

数据范围与提示

Constraints

  • ()