#C2438. Taco: Maximum Building Height
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 , 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 , which represents the number of blocks. The second line contains 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 ).## sample
6
5 3 4 6 7 8
6