func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long infl = 0x3f3f3f3f3f3f3f3fLL;   const long long infi = 0x3f3f3f3f;   const long long mod = infl;   long long mygcd(long long a, long long b) {     if (b == 0) {       return a;     }     return mygcd(b, a % b);   }   long long mypow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   void solve() {     long long n, d;     cin >> n >> d;     vector<long long> pro(n);     for (long long i = 1; i < n - 1; i++) {       cin >> pro[i];     }     vector<vector<long long>> gr(n);     for (long long i = 0; i < n; i++) {       long long x, y;       cin >> x >> y;       gr[i] = {x, y};     }     auto isok = [&](long long x) {       vector<long long> best(n, -1);       best[0] = x;       queue<long long> q;       q.push(0);       while (q.size()) {         long long front = q.front();         q.pop();         for (long long i = 1; i < n; i++) {           if (i == front) {             continue;           }           long long need =               d * (abs(gr[front][0] - gr[i][0]) + abs(gr[front][1] - gr[i][1]));           if (need > best[front]) {             continue;           }           long long new_best = best[front] - need + pro[i];           if (new_best > best[i]) {             best[i] = new_best;             q.push(i);           }         }       }       if (best[n - 1] == -1) {         return false;       }       return true;     };     long long l = 0;     long long r = infi;     while (l < r) {       long long m = (l + r) / 2;       if (isok(m)) {         r = m;       } else {         l = m + 1;       }     }     cout << r <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cout << fixed << setprecision(20);     cin.tie(NULL);     long long t = 1;     while (t--) {       solve();     }     return 0;   }   