#include <bits/stdc++.h>   using namespace std;   int n, d;   int a[200];   int x[200], y[200];   int dis[200];   vector<pair<int, int> > edge[200];   int bellman_ford() {     for (int i = 0; i < n; ++i) dis[i] = 1000000000;     dis[0] = 0;     for (int i = 1; i < n; ++i) {       for (int j = 0; j < n; ++j) {         for (int k = 0, len = edge[j].size(); k < len; ++k)           dis[edge[j][k].first] =               min(dis[edge[j][k].first], dis[j] + edge[j][k].second);       }     }     return max(0, dis[n - 1]);   }   int D(int i, int j) { return abs(x[i] - x[j]) + abs(y[i] - y[j]); }   int main() {     while (cin >> n >> d) {       a[0] = 0;       a[n - 1] = 0;       for (int i = 1; i < n - 1; ++i) cin >> a[i];       for (int i = 0; i < n; ++i) {         cin >> x[i] >> y[i];       }       for (int i = 0; i < n; ++i)         for (int j = 0; j < n; ++j)           if (i != j) {             edge[i].push_back(make_pair(j, D(i, j) * d - a[i]));           }       cout << bellman_ford() << endl;     }     return 0;   }   