DABRI001 - Noel and His Reindeer


The big Noel is a guy full of habits. This year he put all of his reindeer in a row and decided to select the most of them, following a few rules.

  • Reindeer can not be changed in order, i.e. a reindeer that is in position i in the original row should appear before the reindeer j in the chosen list, where i < j.
  • Reindeer of two adjacent positions in the final sequence must differ exactly by 1 (right-left=1) unit in their heights.

If that was not enough, Noel realized that this sequence had few reindeer. So she decided to include a new reindeer in the original row. Taking into account that this new reindeer can be inserted in any position and he will always choose a reindeer with the best possible height.

After making the task a little difficult, Noel ended up getting confused and is asking for your help to find out how many reindeer can be selected taking into account the rules imposed.

Input

The first line of the entry contains an integer N (1 ≤ N ≤ 105) corresponding to the number of reindeer. In the second line contains N integers Xi (1 ≤ Xi ≤ 106) which represents the height of the ith reindeer.

Output

Print as many reindeer as Noel can select.

Example

Input:
4
1 1 2 2

Output:
3

hide comments
smso: 2021-10-27 18:23:38

Unclear problem statement. The only test case should be explained.


Added by:Francisco Elio Parente Arcos Filho [UEA]
Date:2018-12-25
Time limit:1s-2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:https://www.urionlinejudge.com.br/judge/en/challenges/view/412/9