#AT1374. [ABC171D] Replacing
[ABC171D] Replacing
Score : points
Problem Statement
You have a sequence composed of positive integers: .
You will now successively do the following operations:
- In the -th operation, you replace every element whose value is with .
For each , find : the sum of all elements in just after the -th operation.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print integers to Standard Output in the following format:
Note that may not fit into a -bit integer.
Initially, the sequence is .
After each operation, it becomes the following:
Note that the sequence may not contain an element whose value is .