S. Bridging the Gap
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
4 2
1 2 10 5
Output
17
Input
4 6
1 2 10 5
Output
10