#C8421. Tallest Tower
Tallest Tower
Tallest Tower
Alice wants to build the tallest tower possible using a collection of bricks. Each brick has a positive integer height. In order to ensure the structural stability of the tower, no two adjacent bricks in the tower can have the same height. Effectively, this means that Alice can use at most one brick of each distinct height.
Given an integer N and a list of N bricks with their heights, your task is to compute the maximum possible height of the tower. Mathematically, if the set of distinct brick heights is \(S\), then the answer is given by:
[ \text{Total Height} = \sum_{h\in S} h ]
Note: The input may contain duplicate brick heights. Since using two bricks of the same height consecutively is not allowed, only one brick per distinct height can be included in the tower.
inputFormat
The input is read from standard input. The first line contains a single integer N (0 ≤ N ≤ 105) which represents the number of bricks. The second line contains N space-separated integers, where the i-th integer denotes the height of the i-th brick.
outputFormat
Output the maximum total height of the tower to the standard output.
## sample7
1 2 2 3 3 4 4
10