After being trapped and tormented inside of
basement "Art Academy", decided that it was finally time for him to plan an escape. Fortunately, had never actually considered the possibility of him wanting to escape, so the actual escape would be a piece of cake.
Along the Academy, there are a total of paintings spread across the area, each with a value of . Since is short on money, he plans to steal some of the paintings while making his escape. However, because is insecure, all of his paintings' values have been hashed, meaning that the value that sees them at is NOT the actual value. Specifically, the paintings' values have been hashed using the following function:
( represents the hashed value, while represents the original value. It is guaranteed that all integer values of under will be given a unique hash value.)
paintings with the greatest original value.doesn't have the time to figure out the original value of the paintings, and so has asked YOU to create a program for him, that will to maximize his profits. More specifically, he would like you to sum up the
On the first line, there will be two space-separated integers, , and . The next lines will contain a single integer , representing the hashed value of the painting. It is guaranteed that the original value of this hashed number will be greater than , but no greater than .
A single integer, representing the sum of the paintings with the greatest original value.
|3||80||No further constraints.|
5 2 387276917 145972072 2654435761 147926525 2415085369
The original values for the paintings with values , , , , and , are , , , , and , respectively.
The sum of the two greatest values, and , is .