#K95417. Sum of Two Largest Distinct Integers
Sum of Two Largest Distinct Integers
Sum of Two Largest Distinct Integers
You are given a list of integers. Your task is to compute the sum of the two largest distinct integers in the list.
If the list contains fewer than two distinct integers, output the single largest integer. If the list is empty, output \(-1\).
Example:
- For the input
[4, 1, 7, 7, 3, 3, 5]
, the two largest distinct integers are \(7\) and \(5\), so the output is \(7+5=12\).
inputFormat
The input is read from stdin and is formatted as follows:
- The first line contains a single integer \(n\), representing the number of elements in the list.
- The second line contains \(n\) space-separated integers.
If \(n=0\), it means the list is empty.
outputFormat
Output a single integer to stdout following the rules described above.
## sample7
4 1 7 7 3 3 5
12