<a href="https://codeforces.com/contest/242/problem/E">https://codeforces.com/contest/242/problem/E</a>
Input Format
.
Output Format
.
Constraints
.
Example
Input
5 4 10 3 13 7 8 1 2 4 2 1 3 3 1 2 4 1 3 3 2 2 5 5 1 1 5 2 1 2 10 1 2 3
Output
26 22 0 34 11