- Time limit: 2.00 s
- Memory limit: 512 MB
Uolevi wants a yacht, but he is on a tight budget of euros, so he has decided to build his own.
He can spend money on buoyancy, size, and yellow paint. Formally, let be the amount of euros he spends on buoyancy, be the amount of euros spent on size, and the amount of euros spent on yellow paint. The value of the boat will be
where is some function you are given. Find the maximum value the boat can have when Uolevi spends at most euros in total, that is, he chooses , , such that
Input
The first line contains an integer .
The next line contains integers: .
Output
Output a single integer: the maximum value the boat can have.
Constraints
- for all
Example
Input:
11 1 0 5 9 10 2 16 13 0 19 27 6
Output:
30
Explanation:
Uolevi can choose , , to achieve .
Example 2
Input:
0 1000000000
Output:
3000000000