CSES - KILO 2015 2/5 - Zigzag
  • Time limit: 1.00 s
  • Memory limit: 128 MB

Given a sequence of integers a1,a2,,ana_1, a_2, \ldots, a_n, find the length of the longest zigzagging subsequence in it. Sequence s1,s2,,sms_1, s_2, \ldots, s_m is zigzagging if for every 1<i<m1 < i < m: si1<si>si+1s_{i-1} < s_i > s_{i+1} or si1>si<si+1s_{i-1} > s_i < s_{i+1}.

Input

The first line of the input contains integer nn, the length of the sequence. Next line contains nn integers, a1,a2,,ana_1, a_2, \ldots, a_n.

Output

Output the maximum length of a zigzagging subsequence in a1,a2,,ana_1, a_2, \ldots, a_n.

Constraints

  • 1n1051 \le n \le 10^5
  • 1ai1091 \le a_i \le 10^9

Example

Input:

8
5 3 1 2 3 4 2 2

Output:

4

An example of a zigzagging subsequence of length 4 is 3 1 3 2.