eolymp
bolt
Try our new interface for solving problems
Problems

Z-Frog 3

Z-Frog 3

There are n stones, numbered 1, 2, ..., n. For each i (1in), the height of stone i is hi. Here h1 < h2 < ... < hn 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 (hj − hi)^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 (2n2 * 105) and c (1c1012). Second line contains the heights of stones 1h1 < h2 < ... < hn106.

Output

Print the minimum possible total cost incurred.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5 6
1 2 3 4 5
Output example #1
20
Author Michael Medvediev