Fishboats
On a beach with a straight-line shape, there is a fish tavern located at coordinate zero. To the right and left of the fish tavern (in positive and negative coordinates), fishing boats (fishboats) arrive every morning, each bringing kilograms of fish to sell. The tavern owner, knowing that he will have many customers in the evening, wants to buy as many kilograms of fish as possible. Thus, he starts from the tavern exactly when the fishing boats dock on the beach (all simultaneously) and covers a distance of one unit in the unit of time. Each time he reaches a fishing boat, the tavern owner purchases the amount of fish it offers and immediately moves on to the next fishing boat (without any time interval). However, during each unit of time until the tavern owner arrives, each fishing boat sells one kilogram of fish to tourists strolling on the beach. The task is to find the maximum number of kilograms of fish that the tavern owner can buy.
Input Files
The first line of input will contain exactly two positive integers separated by a single space: the values of and . The second line will contain N non-zero integers , , separated by spaces: the coordinates of the points on the beach where the fishing boats arrive.
Output Files
The output should consist of a single line containing exactly one integer: the maximum number of kilograms of fish the tavern owner can buy.
Example of Input - Output Files:
STDIN (phishboats.in)
3 20
8
-2
1
STDOUT (phisboats.out)
41
Constraints
- Τime limit: 1 sec.
Comments