Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official.
×

Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Yaroslav and Time

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYaroslav 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 (*x*_{i}, *y*_{i}) of the plane. As the player visits station number *i*, he increases the current time on his timer by *a*_{i}. 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 |*x*_{i} - *x*_{j}| + |*y*_{i} - *y*_{j}|.

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, 10^{3} ≤ *d* ≤ 10^{5}) — the number of stations and the constant from the statement.

The second line contains *n* - 2 integers: *a*_{2}, *a*_{3}, ..., *a*_{n - 1} (1 ≤ *a*_{i} ≤ 10^{3}). The next *n* lines contain the coordinates of the stations. The *i*-th of them contains two integers *x*_{i}, *y*_{i} (-100 ≤ *x*_{i}, *y*_{i} ≤ 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

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/23/2021 05:21:44 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|