#C2438. Taco: Maximum Building Height

    ID: 45754 Type: Default 1000ms 256MiB

Taco: Maximum Building Height

Taco: Maximum Building Height

You are given a list of blocks, each represented by an integer. Your task is to construct the tallest possible building by arranging some (or all) of these blocks in a sequence such that the difference between the heights of any two consecutive blocks is exactly 11, i.e. (|h_{i+1}-h_i|=1). You may reorder the blocks as needed. If no blocks are provided, the answer is 0.

inputFormat

The first line contains a single integer nn, which represents the number of blocks. The second line contains nn space-separated integers representing the heights of the blocks.

outputFormat

Output a single integer representing the maximum possible height of the building (i.e. the length of the longest sequence of blocks that can be arranged to satisfy hi+1hi=1|h_{i+1}-h_i|=1).## sample

6
5 3 4 6 7 8
6