Richard has N gold coins. Each coin has a value associated with it. Richard is too bored after acing his mid-semester examinations. He decides to conduct an experiment that lasts for M days. Each day, Richard can pick any positive number of coins and find the sum of their values. But the value of the chosen coins decreases by K each. Help Richard find the maximum possible cumulative sum at the end of the experiment.
Note : Cumulative sum means the total sum obtained by summing the result he gets each day. Also, the values associated with the coins can become negative during the course of the experiment! The answer can be negative too!
The first line consists of 3 integers N, M and K respectively.
N integers follow, where the integer () denotes the initial value associated with the coin.
Print a single integer denoting the answer modulo . Note that answer modulo is always non-negative even if answer is negative.
Subtask | Points |
---|---|
Original Constraints |
Let the coins having values 1, 2 and 3 be referred as A, B and C respectively.
Day 1 - Richard picks A ,B and C
Values - 0, 1, 2
Sum = 6
Day 2 - Richard picks B and C
Values - 0, 0, 1
Sum = 9
Day 3 - Richard picks C
Values - 0, 0, 0
Sum = 10