#C7110. Largest Sum of Unique Pages

    ID: 50946 Type: Default 1000ms 256MiB

Largest Sum of Unique Pages

Largest Sum of Unique Pages

In this problem, the king wants to maximize his reading by summing up the number of pages from a library's collection, but he refuses to read books with duplicate page counts. Formally, given a set of books with page counts, you need to compute the sum over the unique page counts. That is, if ( U ) is the set of unique page counts, then compute ( S = \sum_{x \in U} x ).

Given the total number of books ( n ) and a list of ( n ) integers representing the page count of each book, output the largest possible sum of pages considering each distinct page count only once.

inputFormat

The input is read from standard input (stdin) and consists of two lines. The first line contains a single integer ( n ), which is the number of books. The second line contains ( n ) space-separated integers, where each integer represents the number of pages in a book.

outputFormat

Output a single integer to standard output (stdout) which is the sum of the unique page counts from the input.## sample

5
100 200 300 400 500
1500