A company is responsible for constructing $n$ electric poles for a city. The $i$-th electric pole has a height of $h_i$. In order to maintain urban aesthetics, the city has imposed a regulation that the company will be charged a cost based on the height difference between two adjacent poles $i$ and $i + 1$, given by $c_i \times |h_i - h_{i+1}|$. Additionally, the height difference between two neighboring poles must not exceed $d$.
To meet these requirements, the company can increase the height of certain poles. However, increasing the height of the $i$-th pole by $x$ units will incur a cost of $x^2$. Find the minimum cost required to comply with the city's regulations.
### Input
- The first line contains two integer $n,d$.
- The second line contains $n - 1$ integers $c_i$ with $1 \le i \le n - 1$.
- The third line contain $n$ integers $h_i$.
### Output
- Print an integer, the minimum cost.
### Constraints
- $1 \le n, d, h_i \le 5000$.
- $1 \le c_i \le 10^4$.
### Example
Input:
```
5 4
2 2 2 2
2 3 5 1 4
```
Output:
```
15
```