301_B. Yaroslav and Time
Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has n clock stations, station number i is at point (xi, yi) of the plane. As the player visits station number i, he increases the current time on his timer by ai. The stations are for one-time use only, so if the player visits some station another time, the time on his timer won't grow.

A player spends d·dist time units to move between stations, where dist is the distance the player has covered and d is some constant. The distance between stations i and j is determined as |xi - xj| + |yi - yj|.

Initially, the player is at station number 1, and the player has strictly more than zero and strictly less than one units of time. At station number 1 one unit of money can increase the time on the timer by one time unit (you can buy only integer number of time units).

Now Yaroslav is wondering, how much money he needs to get to station n. Help Yaroslav. Consider the time to buy and to increase the timer value negligibly small.

Input

The first line contains integers n and d (3 ≤ n ≤ 100, 103 ≤ d ≤ 105) — the number of stations and the constant from the statement.

The second line contains n - 2 integers: a2, a3, ..., an - 1 (1 ≤ ai ≤ 103). The next n lines contain the coordinates of the stations. The i-th of them contains two integers xi, yi (-100 ≤ xi, yi ≤ 100).

It is guaranteed that no two stations are located at the same point.

Output

In a single line print an integer — the answer to the problem.

Examples

Input

3 1000
1000
0 0
0 1
0 3


Output

2000


Input

3 1000
1000
1 0
1 1
1 2


Output

1000
```python
import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n, dc = mints()
	a = list(mints())
	a.append(0)
	x = [0]*n
	y = [0]*n
	for i in range(n):
		x[i], y[i] = mints()
	d = [1<<30]*n
	d[0] = 0
	was = [False]*n
	for i in range(n):
		m = 1<<30
		mi = 0
		for j in range(n):
			if not was[j] and m > d[j]:
				m = d[j]
				mi = j
		j = mi
		was[j] = True
		for k in range(n):
			if not was[k]:
				dd = d[j] + (abs(x[k]-x[j])+abs(y[k]-y[j]))*dc
				dd -= a[k-1]
				if d[k] > dd:
					d[k] = dd
	print(d[-1])

solve()

```