Z-Frog 3
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
There are n stones, numbered 1, 2, ..., n. For each i (1 ≤ i ≤ n), the height of stone i is h[i]
. Here h[1]
< h[2]
< ... < h[n]
holds.
There is a frog who is initially on stone 1. He will repeat the following action some number of times to reach stone n:
If the frog is currently on Stone i, jump to one of the following: stone i + 1, i + 2, ..., n. Here, a cost of
(h[j] − h[i])^2
+ c is incurred, where j is the stone to land on.
Find the minimum possible total cost incurred before the frog reaches stone n.
Input
First line contains two integers n (2 ≤ n ≤ 2 * 10^5
) and c (1 ≤ c ≤ 10^12
). Second line contains the heights of stones 1 ≤ h[1]
< h[2]
< ... < h[n]
≤ 10^6
.
Output
Print the minimum possible total cost incurred.
Examples
Input #1
Answer #1
Submissions 53
Acceptance rate 40%