import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9) + 7;
    static int time = 1;

    public static void main(String[] args) throws FileNotFoundException {

        //PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        final long d = in.nextInt();
        int[] data = new int[n - 2];

        for (int i = 0; i < n - 2; i++) {
            data[i] = in.nextInt();
        }
        Entry[] en = new Entry[n];
        for (int i = 0; i < n; i++) {
            en[i] = new Entry(in.nextInt(), in.nextInt(), 0);
            if (i != 0 && i != n - 1) {
                en[i].c = data[i - 1];
            }
        }
        Entry s = en[0];
        final Entry e = en[n - 1];
        Arrays.sort(en, new Comparator<Entry>() {
            @Override
            public int compare(Entry o1, Entry o2) {
                long a = Math.abs(o1.x - e.x) + Math.abs(o1.y - e.y);
                a = a * d - o1.c;
                long b = Math.abs(o2.x - e.x) + Math.abs(o2.y - e.y);
                b = b * d - o2.c;
                if (a != b) {
                    return Long.compare(a, b);
                } else {
                    if (e == o1) {
                        return -1;
                    } else if (e == o2) {
                        return 1;
                    }else{
                        return 0;
                    }
                }
            }
        });

        int start = -1;
        int end = -1;
        for (int i = 0; i < n; i++) {
            if (en[i] == s) {
                start = i;
            }
            if (en[i] == e) {
                end = i;
            }
        }
       // System.out.println(start + " " + end);
        long result = cal(end, start, d, en);
        out.println(result);
        out.close();

    }

    static long cal(int index, int end, long d, Entry[] e) {
        if (index == end) {
            return 0;
        }
        long result = Long.MAX_VALUE;
        for (int i = index + 1; i <= end; i++) {
            long tmp = d * (long) (Math.abs(e[index].x - e[i].x) + Math.abs(e[index].y - e[i].y)) - e[i].c;
            tmp += cal(i, end, d, e);
            if (tmp < result) {
                result = tmp;
            }
        }
        return result;
    }

    static class Entry {

        int x, y;
        long c;

        public Entry(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }

        @Override
        public String toString() {
            return "Entry{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static int find(int index, int[] u) {
        if (index != u[index]) {
            return u[index] = find(u[index], u);
        }
        return index;
    }

    public static long pow(int a, int b, long mod) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long v = pow(a, b / 2, mod);
        if (b % 2 == 0) {
            return (v * v) % mod;
        } else {
            return (((v * v) % mod) * a) % mod;
        }
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;

    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9) + 7;
    static int time = 1;

    public static void main(String[] args) throws FileNotFoundException {

        //PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        final long d = in.nextInt();
        int[] data = new int[n - 2];

        for (int i = 0; i < n - 2; i++) {
            data[i] = in.nextInt();
        }
        Entry[] en = new Entry[n];
        for (int i = 0; i < n; i++) {
            en[i] = new Entry(in.nextInt(), in.nextInt(), 0);
            if (i != 0 && i != n - 1) {
                en[i].c = data[i - 1];
            }
        }
        Entry s = en[0];
        final Entry e = en[n - 1];
        Arrays.sort(en, new Comparator<Entry>() {
            @Override
            public int compare(Entry o1, Entry o2) {
                long a = Math.abs(o1.x - e.x) + Math.abs(o1.y - e.y);
                a = a * d - o1.c;
                long b = Math.abs(o2.x - e.x) + Math.abs(o2.y - e.y);
                b = b * d - o2.c;
                return Long.compare(a, b);
            }
        });

        int start = -1;
        int end = -1;
        for(int i = 0; i < n; i++){
            if(en[i] == s){
                start = i;
            }
            if(en[i] == e){
                end = i;
            }
        }
       // System.out.println(start + " " + end);
        long result = cal(end, start, d,en);
        out.println(result);
        out.close();

    }

    static long cal(int index, int end,long d, Entry[]e){
        if(index == end){
            return 0;
        }
        long result = Long.MAX_VALUE;
        for(int i = index + 1; i <= end; i++){
            long tmp = d*(long)(Math.abs(e[index].x - e[i].x) + Math.abs(e[index].y - e[i].y)) - e[i].c;
            tmp += cal(i, end, d, e);
            if(tmp < result){
                result = tmp;
            }
        }
        return result;
    }

    static class Entry {

        int x, y;
        long c;

        public Entry(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }

        @Override
        public String toString() {
            return "Entry{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static int find(int index, int[] u) {
        if (index != u[index]) {
            return u[index] = find(u[index], u);
        }
        return index;
    }

    public static long pow(int a, int b, long mod) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long v = pow(a, b / 2, mod);
        if (b % 2 == 0) {
            return (v * v) % mod;
        } else {
            return (((v * v) % mod) * a) % mod;
        }
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;

    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9) + 7;
    static int time = 1;
    static long[]dp;

    public static void main(String[] args) throws FileNotFoundException {

        //PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        final long d = in.nextInt();
        int[] data = new int[n - 2];

        for (int i = 0; i < n - 2; i++) {
            data[i] = in.nextInt();
        }
        dp = new long[n];
        Arrays.fill(dp,-1);
        Entry[] en = new Entry[n];
        for (int i = 0; i < n; i++) {
            en[i] = new Entry(in.nextInt(), in.nextInt(), 0);
            if (i != 0 && i != n - 1) {
                en[i].c = data[i - 1];
            }
        }
        Entry s = en[0];
        final Entry e = en[n - 1];
        Arrays.sort(en, new Comparator<Entry>() {
            @Override
            public int compare(Entry o1, Entry o2) {
                long a = Math.abs(o1.x - e.x) + Math.abs(o1.y - e.y);
                a = a * d ;
                long b = Math.abs(o2.x - e.x) + Math.abs(o2.y - e.y);
                b = b * d ;
                if (a != b) {
                    return Long.compare(a, b);
                } else {
                    if (e == o1) {
                        return -1;
                    } else if (e == o2) {
                        return 1;
                    }else{
                        return Long.compare(o2.c, o1.c);
                    }
                }
            }
        });

        int start = -1;
        int end = -1;
        for (int i = 0; i < n; i++) {
            if (en[i] == s) {
                start = i;
            }
            if (en[i] == e) {
                end = i;
            }
        }
       // System.out.println(start + " " + end);
        long result = cal(end, start, d, en);
        out.println(result);
        out.close();

    }

    static long cal(int index, int end, long d, Entry[] e) {
        if (index == end) {
            return 0;
        }
        if(dp[index] != -1){
            return dp[index];
        }
        long result = Long.MAX_VALUE;
        for (int i = index + 1; i <= end; i++) {
            long tmp = d * (long) (Math.abs(e[index].x - e[i].x) + Math.abs(e[index].y - e[i].y)) - e[i].c;
            tmp += cal(i, end, d, e);
            if (tmp < result) {
                result = tmp;
            }
        }
        return dp[index] = result;
    }

    static class Entry {

        int x, y;
        long c;

        public Entry(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }

        @Override
        public String toString() {
            return "Entry{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static int find(int index, int[] u) {
        if (index != u[index]) {
            return u[index] = find(u[index], u);
        }
        return index;
    }

    public static long pow(int a, int b, long mod) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long v = pow(a, b / 2, mod);
        if (b % 2 == 0) {
            return (v * v) % mod;
        } else {
            return (((v * v) % mod) * a) % mod;
        }
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;

    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9) + 7;
    static int time = 1;
    static long[] dp;

    public static void main(String[] args) throws FileNotFoundException {

        //PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        final long d = in.nextInt();
        int[] data = new int[n - 2];

        for (int i = 0; i < n - 2; i++) {
            data[i] = in.nextInt();
        }
        dp = new long[n];
        Arrays.fill(dp, -1);
        Entry[] en = new Entry[n];
        for (int i = 0; i < n; i++) {
            en[i] = new Entry(in.nextInt(), in.nextInt(), 0);
            if (i != 0 && i != n - 1) {
                en[i].c = data[i - 1];
            }
        }
        final Entry s = en[0];
        final Entry e = en[n - 1];

        Arrays.sort(en, 1, n - 1, new Comparator<Entry>() {
            @Override
            public int compare(Entry o1, Entry o2) {
                long a = Math.abs(o1.x - e.x) + Math.abs(o1.y - e.y);

                long b = Math.abs(o2.x - e.x) + Math.abs(o2.y - e.y);

                if (a != b) {
                    return Long.compare(b, a);
                } else {
                    return Long.compare(o1.c, o2.c);
                }
            }
        });
        //System.out.println(Arrays.toString(en));

        int start = -1;
        int end = -1;
        for (int i = 0; i < n; i++) {
            if (en[i] == s) {
                start = i;
            }
            if (en[i] == e) {
                end = i;
            }
        }
        // System.out.println(start + " " + end);
        long result = cal(0, n - 1, d, en);
        out.println(result);
        out.close();

    }

    static long cal(int index, int end, long d, Entry[] e) {
        if (index == end) {
            return 0;
        }
        if (dp[index] != -1) {
            return dp[index];
        }
        long result = Long.MAX_VALUE;
        for (int i = index + 1; i <= end; i++) {
            long tmp = d * (long) (Math.abs(e[index].x - e[i].x) + Math.abs(e[index].y - e[i].y)) - e[i].c;
            tmp += cal(i, end, d, e);
            if (tmp < result) {
                result = tmp;
            }
        }
        return dp[index] = result;
    }

    static class Entry {

        int x, y;
        long c;

        public Entry(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }

        @Override
        public String toString() {
            return "Entry{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static int find(int index, int[] u) {
        if (index != u[index]) {
            return u[index] = find(u[index], u);
        }
        return index;
    }

    public static long pow(int a, int b, long mod) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long v = pow(a, b / 2, mod);
        if (b % 2 == 0) {
            return (v * v) % mod;
        } else {
            return (((v * v) % mod) * a) % mod;
        }
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;

    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


//package codeforces.archive;

import java.io.*;

public class Problem301B {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    int[] readInts() throws IOException {
        String line = reader.readLine();
        String []s = line.split(" ");
        int[] ret = new int[s.length];
        for(int i = 0; i < s.length; i++) {
            ret[i] = Integer.parseInt(s[i]);
        }
        return ret;
    }

    int[] tt = null;
    int ti = 0;
    int readInt() throws IOException {
        if(tt == null || ti == tt.length) {
            tt = readInts();
            ti = 0;
        }
        return tt[ti++];
    }

    void solve() throws IOException {
        int n = readInt();
        final int d = readInt();
        int[] a = new int[n];
        for(int i = 1; i < n - 1; i++) {
            a[i] = readInt();
        }
        final int[][] coords = new int[n][];
        for(int i = 0; i < n; i++) coords[i] = readInts();
        class D {
            int dist(int i, int j) {
                return d * (Math.abs(coords[i][0] - coords[j][0]) + Math.abs(coords[i][1] - coords[j][1]));
            }
        }
        D dd = new D();
        int lo = 0, hi = 1000 * 1000 * 1000;
        while(hi - lo > 1) {
            int med = lo + hi >> 1;
            int[] fuel = new int[n + 1];
            for(int i = 0; i <= n; i++) fuel[i] = Integer.MIN_VALUE;
            boolean[] used = new boolean[n];
            fuel[0] = med;
            for(int k = 1; k < n; k++) {
                int u = n;
                for(int i = 0; i < n; i++) {
                    if(!used[i] && fuel[i] > fuel[u]) {
                        u = i;
                    }
                }
                if(u == n || fuel[u] < 0) break;
                used[u] = true;
                fuel[u] += a[u];
                for(int v = 0; v < n; v++) {
                    fuel[v] = Math.max(fuel[v], fuel[u] - dd.dist(u, v));
                }
            }
            if(fuel[n - 1] >= 0) hi = med;
            else lo = med;
        }
        writer.println(hi);
        writer.flush();
    }

    public static void main(String[] args) throws IOException {
        new Problem301B().solve();
    }
}


import java.util.*;

public class Main {
	static int n, d, a[], x[], y[];
	static int dis[];
	static boolean f[];
	static int abs(int k) {
		return k>0?k:-k;
	}
	static int min(int a1, int a2) {
		return a1<a2?a1:a2;
	}
	static int dis(int u, int v) {
		int ret = d*abs(x[u]-x[v])+d*abs(y[u]-y[v])-a[u];
		if (ret < 0) ret = 0;
		return ret;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		d = in.nextInt();
		a = new int[111];
		x = new int[111];
		y = new int[111];
		dis = new int[111];

		for (int i=2; i<n; i++)
			a[i] = in.nextInt();
		for (int i=1; i<=n; i++) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}

		f = new boolean[111];
		for (int i=1; i<=n; i++) dis[i] = 11111111;
		for (int i=1; i<=n; i++) f[i] = false;

		dis[n] = 0;
		f[n] = true;
		int now = n;
		for (int cnt=0; cnt<n-1; cnt++) {
			for (int i=1; i<=n; i++) {
				if (f[i] == true) continue;
				dis[i] = min(dis[i], dis[now]+dis(i, now));
			}
			int temp = 11111111;
			for (int i=1; i<=n; i++) {
				if (f[i] == true) continue;
				if (dis[i] < temp) {
					temp = dis[i];
					now = i;
				}
			}
			f[now] = true;
		}
		System.out.println(dis[1]);
	}
}


import java.util.*;

public class Main {
	static int n, d, a[], x[], y[];
	static int dis[];
	static boolean f[];
	static int abs(int k) {
		return k>0?k:-k;
	}
	static int min(int a1, int a2) {
		return a1<a2?a1:a2;
	}
	static int dis(int u, int v) {
		int ret = d*abs(x[u]-x[v])+d*abs(y[u]-y[v])-a[u];
		if (ret < 0) ret = 0;
		return ret;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		d = in.nextInt();
		a = new int[111];
		x = new int[111];
		y = new int[111];
		dis = new int[111];

		for (int i=2; i<n; i++)
			a[i] = in.nextInt();
		for (int i=1; i<=n; i++) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
		}

		f = new boolean[111];
		for (int i=1; i<=n; i++) dis[i] = 111111111;
		for (int i=1; i<=n; i++) f[i] = false;

		dis[n] = 0;
		f[n] = true;
		int now = n;
		for (int cnt=0; cnt<n-1; cnt++) {
			for (int i=1; i<=n; i++) {
				if (f[i] == true) continue;
				dis[i] = min(dis[i], dis[now]+dis(i, now));
			}
			int temp = 111111111;
			for (int i=1; i<=n; i++) {
				if (f[i] == true) continue;
				if (dis[i] < temp) {
					temp = dis[i];
					now = i;
				}
			}
			f[now] = true;
		}
		System.out.println(dis[1]);
	}
}


import static java.lang.System.*;
import static java.lang.Math.*;

import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class B301 {
    public static Scanner sc=new Scanner(in);
    //public static Random sc=new Random();

    void warshall_floyd(int[][] d){
        for(int k=0;k<d.length;k++)
            for(int i=0;i<d.length;i++)for(int j=0;j<d[0].length;j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    void run() throws RuntimeException{
        final int n=sc.nextInt(),d=sc.nextInt();

        int[] as=new int[n];
        for(int i=1;i<=n-2;i++)as[i]=sc.nextInt();

        int[] xs=new int[n],ys=new int[n];
        for(int i=0;i<n;i++){
            xs[i]=sc.nextInt();ys[i]=sc.nextInt();
        }

        int[][] dmap=new int[n][n];
        for(int h=0;h<n;h++)for(int w=0;w<n;w++){
            if(h==w)dmap[h][w]=0;
            else dmap[h][w]=d*(abs(xs[h]-xs[w])+abs(ys[h]-ys[w]))-as[w];
        }

        for(int k=0;k<dmap.length;k++)
            for(int i=0;i<dmap.length;i++)for(int j=0;j<dmap.length;j++)
                    dmap[i][j] = min(dmap[i][j], dmap[i][k] + dmap[k][j]);

        ln(dmap[0][n-1]);
    }

    public static void main(String[] args) {
        new B301().run();
    }

    //output lib
    static final String br=System.getProperty("line.separator");
    static final String[] asep=new String[]{""," ",br,br+br};
    static String str(boolean o){
        return o?"YES":"NO";
    }
    static <K,V> String str(Map<K, V> map){
        StringBuilder sb=new StringBuilder();
        boolean isFirst=true;
        for(Entry<K,V> set:map.entrySet()){
            if(!isFirst)sb.append(br);
            sb.append(str(set.getKey())).append(":").append(str(set.getValue()));
            isFirst=false;
        }
        return sb.toString();
    }
    static <E> String str(Collection<E> list){
        StringBuilder sb=new StringBuilder();
        boolean isFirst=true;
        for(E e:list){
            if(!isFirst)sb.append(" ");
            sb.append(str(e));
            isFirst=false;
        }
        return sb.toString();
    }
    static String str(Object o){
        int depth=_getArrayDepth(o);
        if(depth>0)return _strArray(o,depth);
        return o.toString();
    }
    static int _getArrayDepth(Object o){
        if(!o.getClass().isArray() || Array.getLength(o)==0) return 0;
        return  1+_getArrayDepth(Array.get(o,0));
    }
    //depth ex A[10]…1 A[10][10]…2 exception A[0]…0 A[10][0]…1 A[0][0]…0
    static String _strArray(Object o,int depth){
        if(depth==0) return str(o);
        StringBuilder sb=new StringBuilder();
        for(int i=0,len=Array.getLength(o);i<len;i++){
            if(i!=0)sb.append(asep[depth]);
            sb.append(_strArray(Array.get(o,i),depth-1));
        }
        return sb.toString();
    }
    static void pr(Object... os){
        boolean isFirst=true;
        for(Object o:os){
            if(!isFirst)out.print(" ");
            out.print(o);
            isFirst=false;
        }
    }
    static void ln(){
        out.println();
    }
    static void ln(Object... os){
        for(Object o:os){
            pr(o);ln();
        }
    }
}


import java.io.*;
import java.math.*;
import java.util.*;

public class Solution {
    InputReader reader;
    PrintWriter writer;

    Solution() {
        reader = new InputReader();
        writer = new PrintWriter(System.out);
    }

    public static void main(String[] args) {
        new Solution().run();
    }

    public void run() {
        try {
            int n = reader.nextInt();
            int d = reader.nextInt();
            int[] a = new int[n];
            for (int i = 1; i < n - 1; ++ i) {
                a[i] = reader.nextInt();
            }
            int[] x = new int[n];
            int[] y = new int[n];
            for (int i = 0; i < n; ++ i) {
                x[i] = reader.nextInt();
                y[i] = reader.nextInt();
            }
            int[] need = new int[n];
            Arrays.fill(need, Integer.MAX_VALUE);
            need[n - 1] = 0;
            boolean[] visit = new boolean[n];
            while (true) {
                int u = -1;
                for (int i = 0; i < n; ++ i) {
                    if (!visit[i] && (u == -1 || need[i] < need[u])) {
                        u = i;
                    }
                }
                if (u == -1) {
                    break;
                }
                visit[u] = true;
                for (int v = 0; v < n; ++ v) {
                    if (u != v) {
                        int cost = d * (Math.abs(x[u] - x[v]) + Math.abs(y[u] - y[v]));
                        int newValue = Math.max(need[u] + cost - a[v], 0);
                        if (newValue < need[v]) {
                            need[v] = newValue;
                        }
                    }
                }
            }
            writer.println(need[0]);
        } catch (IOException ex) {
        }
        writer.close();
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    InputReader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    Integer nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

public class R301B implements Runnable {

	class Vertex implements Comparable<Vertex> {
		int pos, time;

		public Vertex(int pos, int time) {
			this.pos = pos;
			this.time = time;
		}

		public int compareTo(Vertex a) {
			 if (this.time == a.time)
				 return this.pos - a.pos;
			 return a.time - this.time;
		}
	}

	private int dist(int i, int j) {
		return (Math.abs(x[i] - x[j]) + Math.abs(y[i] - y[j])) * d;
	}

	private boolean possible(int add) {
		int[] time = new int[n];
		Arrays.fill(time, Integer.MIN_VALUE/3);
		time[0] = add;

		for (int i = 0; i < n-1; ++i) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < n; ++k) {
					if (k == j) {
						continue;
					}

					if (time[k] < time[j] - dist(j, k) + a[k]) {
						time[k] = time[j] - dist(j, k) + a[k];
					}
				}
			}
		}

		if (time[n-1] > 0) {
			return true;
		}
		return false;
	}

	int n;
	int d;
	int[] a;
	int[] x;
	int[] y;
	public void run() {
		n = nextInt();
		d = nextInt();
		a = new int[n];
		x = new int[n];
		y = new int[n];

		for (int i = 1; i < n-1; ++i) {
			a[i] = nextInt();
		}

		for (int i = 0; i < n; ++i) {
			x[i] = nextInt();
			y[i] = nextInt();
		}

		int l = 0;
		int r = 1000000000;

		while (r - l > 1) {
			int mid = (l+r)/2;

			if (possible(mid)) {
				r = mid;
			}
			else {
				l = mid;
			}
		}

		if (possible(l)) {
			out.println(l-1);
		}
		else if (possible(r)){
			out.println(r-1);
		}
		out.flush();
	}

	private static BufferedReader br = null;
	private static PrintWriter out = null;
	private static StringTokenizer stk = null;

	public static void main(String[] args) {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		(new Thread(new R301B())).start();
	}

	private void loadLine() {
		try {
			stk = new StringTokenizer(br.readLine());
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}

	private String nextLine() {
		try {
			return br.readLine();
		}
		catch (IOException e) {
			return null;
		}
	}

	private int nextInt() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return Integer.parseInt(stk.nextToken());
	}

	private long nextLong() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return Long.parseLong(stk.nextToken());
	}

	private double nextDouble() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return Double.parseDouble(stk.nextToken());
	}

	private String nextWord() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return (stk.nextToken());
	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

public class R301B implements Runnable {

	class Vertex implements Comparable<Vertex> {
		int pos, time;

		public Vertex(int pos, int time) {
			this.pos = pos;
			this.time = time;
		}

		public int compareTo(Vertex a) {
			 if (this.time == a.time)
				 return this.pos - a.pos;
			 return a.time - this.time;
		}
	}

	private int dist(int i, int j) {
		return (Math.abs(x[i] - x[j]) + Math.abs(y[i] - y[j])) * d;
	}

	private boolean possible(int add) {
		int[] time = new int[n];
		Arrays.fill(time, Integer.MIN_VALUE/3);
		time[0] = add;

		for (int i = 0; i < n-1; ++i) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < n; ++k) {
					if (k == j) {
						continue;
					}

					if (time[k] < time[j] - dist(j, k) + a[k]) {
						time[k] = time[j] - dist(j, k) + a[k];
					}
				}
			}
		}

		if (time[n-1] > 0) {
			return true;
		}
		return false;
	}

	int n;
	int d;
	int[] a;
	int[] x;
	int[] y;
	public void run() {
		n = nextInt();
		d = nextInt();
		a = new int[n];
		x = new int[n];
		y = new int[n];

		for (int i = 1; i < n-1; ++i) {
			a[i] = nextInt();
		}

		for (int i = 0; i < n; ++i) {
			x[i] = nextInt();
			y[i] = nextInt();
		}

		int l = 0;
		int r = 201 * 100000;

		while (r - l > 1) {
			int mid = (l+r)/2;

			if (possible(mid)) {
				r = mid;
			}
			else {
				l = mid;
			}
		}

		if (possible(l)) {
			out.println(l-1);
		}
		else if (possible(r)){
			out.println(r-1);
		}
		out.flush();
	}

	private static BufferedReader br = null;
	private static PrintWriter out = null;
	private static StringTokenizer stk = null;

	public static void main(String[] args) {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		(new Thread(new R301B())).start();
	}

	private void loadLine() {
		try {
			stk = new StringTokenizer(br.readLine());
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}

	private String nextLine() {
		try {
			return br.readLine();
		}
		catch (IOException e) {
			return null;
		}
	}

	private int nextInt() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return Integer.parseInt(stk.nextToken());
	}

	private long nextLong() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return Long.parseLong(stk.nextToken());
	}

	private double nextDouble() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return Double.parseDouble(stk.nextToken());
	}

	private String nextWord() {
		while (stk==null||!stk.hasMoreElements()) loadLine();
		return (stk.nextToken());
	}
}


#include <bits/stdc++.h>
using namespace std;

int n, d, a[105], adj[105][105], x[105], y[105];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> d;
	for (int i = 2; i <= n - 1; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i == j) {
				adj[i][j] = 1e9;
				continue;
			}

			adj[i][j] = (abs(x[i] - x[j]) + abs(y[i] - y[j])) * d - a[i];
		}
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
			}
		}
	}

	cout << max(0, adj[1][n]) << '\n';

	return 0;
}//hello


#include<bits/stdc++.h>
using namespace std;
const int N=105,inf=1e18;
long long cur,n,d,a[N],x[N],y[N],dp[N],l,r,mid;
inline bool check(long long r){
    for(int i=2;i<=n;i++){
        dp[i]=-inf;
    }
    dp[1]=r;
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int i=1;i<=n;i++){
            if(v!=i){
                cur=dp[v]-(abs(x[i]-x[v])+abs(y[i]-y[v]))*d+a[v];
                if(dp[i]<cur){
                    dp[i]=cur;
                    q.push(i);
                }
            }
        }
    }
    return dp[n]>=0;
}
int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>d;
    for(int i=2;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
    }

    r=inf;
    while(r-l>1){
        mid=(r+l)>>1;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    if(check(r)){
        cout<<r;
    }
    else{
        cout<<l;
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=105,inf=1e18;
long long cur,n,d,a[N],x[N],y[N],dp[N],l,r,mid;
inline bool check(long long r){
    for(int i=2;i<=n;i++){
        dp[i]=-inf;
    }
    dp[1]=r;
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int i=1;i<=n;i++){
            if(v!=i){
                cur=dp[v]-(abs(x[i]-x[v])+abs(y[i]-y[v]))*d+a[v];
                if(dp[i]<cur){
                    dp[i]=cur;
                    q.push(i);
                }
            }
        }
    }
    return dp[n]>0;
}
int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>d;
    for(int i=2;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
    }

    r=inf;
    while(r-l>1){
        mid=(r+l)>>1;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    if(check(l)){
        cout<<l;
    }
    else{
        cout<<r;
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=105,inf=1e18;
long long n,c,a[N],x[N],y[N],d[N];
int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>c;
    for(int i=2;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        d[i]=inf;
    }
    set<pair<long long,int> >q;
    d[1]=0;
    q.insert(make_pair(0,1));
    while(!q.empty()){
        int v=q.begin()->second;
        long long len=q.begin()->first;
        q.erase(q.begin());
        for(int i=1;i<=n;i++){
            if(i!=v && d[i]>(abs(x[i]-x[v])+abs(y[i]-y[v]))*c+len-a[i]){
                q.erase(make_pair(d[i],i));
                d[i]=(abs(x[i]-x[v])+abs(y[i]-y[v]))*c+len-a[i];
                q.insert(make_pair(d[i],i));
            }
        }
    }
    cout<<d[n];
}


#include<bits/stdc++.h>
using namespace std;
const int N=105,inf=1e18;
long long cur,n,d,a[N],x[N],y[N],dp[N],l,r,mid;
inline bool check(long long r){
    for(int i=2;i<=n;i++){
        dp[i]=-inf;
    }
    dp[1]=r;
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int i=1;i<=n;i++){
            if(v!=i){
                cur=dp[v]-(abs(x[i]-x[v])+abs(y[i]-y[v]))*d+a[v];
                if(dp[i]<cur){
                    dp[i]=cur;
                    q.push(i);
                }
            }
        }
    }
    return dp[n]>0;
}
int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>d;
    for(int i=2;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
    }

    r=inf;
    while(r-l>1){
        mid=(r+l)>>1;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    if(check(r)){
        cout<<r;
    }
    else{
        cout<<l;
    }
}


#include<bits/stdc++.h>
using namespace std;

#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int,int> ii;
typedef pair<ll,ll>  pll;

int n,x[110],y[110];
ll memo[110],d,arr[110];
ll solve(int cur){
	if(cur==n-1)return 0;
	ll &ret=memo[cur];
	if(ret!=1e18)return ret;
	ret=-1e18;
	lop(i,n){
		if(i!=cur&&abs(x[i]-x[n-1])<=abs(x[cur]-x[n-1])&&abs(y[i]-y[n-1])<=abs(y[cur]-y[n-1]))
			ret=max(ret,-d*abs(x[i]-x[cur])-d*abs(y[i]-y[cur])+solve(i));
	}
	ret+=arr[cur];
	return ret;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("i.txt","r",stdin);
#endif
    lop(i,110)memo[i]=1e18;
    sc(n),sc(d);
    lop(i,n-2)sc(arr[i+1]);
    lop(i,n)sc(x[i]),sc(y[i]);
    cout<<-solve(0);

}


#include<bits/stdc++.h>
using namespace std;

#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int,int> ii;
typedef pair<ll,ll>  pll;

int n,x[110],y[110],vis[110];
ll d,arr[110];

struct node{
	ll id,time,minTime;
	node(ll a,ll b,ll c):id(a),time(b),minTime(c){};
	bool operator<(node b)const{
		return minTime<b.minTime;
	}
};

ll dijkstra(){
	priority_queue<node> q;
	q.push(node(0,0,0));
	while(!q.empty()){
		ll id=q.top().id,time=q.top().time,minTime=q.top().minTime;
		q.pop();
		if(vis[id])continue;
		vis[id]=1;
		if(id==n-1)return minTime;
		lop(i,n){
			if(!vis[i]){
				q.push(node(i,time-d*abs(x[i]-x[id])-d*abs(y[i]-y[id])+arr[i],min(minTime,time-d*abs(x[i]-x[id])-d*abs(y[i]-y[id]))));
			}
		}
	}
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("i.txt","r",stdin);
#endif
    sc(n),sc(d);
    lop(i,n-2)sc(arr[i+1]);
    lop(i,n)sc(x[i]),sc(y[i]);
    cout<<-dijkstra();
}


#include<bits/stdc++.h>
using namespace std;

#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int,int> ii;
typedef pair<ll,ll>  pll;

int n,x[110],y[110];
ll memo[110],d,arr[110];
ll solve(int cur){
	if(cur==n-1)return 0;
	ll &ret=memo[cur];
	if(ret!=1e18)return ret;
	ret=-1e18;
	lop(i,n){
		if(i!=cur)
			ret=max(ret,-d*abs(x[i]-x[cur])-d*abs(y[i]-y[cur])+solve(i));
	}
	ret+=arr[cur];
	return ret;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("i.txt","r",stdin);
#endif
    lop(i,110)memo[i]=1e18;
    sc(n),sc(d);
    lop(i,n-2)sc(arr[i+1]);
    lop(i,n)sc(x[i]),sc(y[i]);
    cout<<-solve(0);

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll, ll> ii;
typedef pair <ll, ii> iii;

const ll N = 1e6 + 5;
const ll INF = 1e9 + 7;

struct point
{
    ll x, y;
    point (ll x, ll y) : x(x), y(y) {}
    point () {}
    inline friend ll Dist (const point &lhs, const point &rhs)
    {
        return abs(lhs.x - rhs.x) + abs(lhs.y - rhs.y);
    }
} a[N];

ll n, d, c[N], xSrc, ySrc, xDst, yDst, ans;
bool mark[N];

inline bool Check (ll limit)
{
    ll xCur = xSrc, yCur = ySrc;
    for (ll i = 2; i <= n; i++) mark[i] = true;
    while (xCur != xDst || yCur != yDst)
    {
        ll cur = 0, pos = -1;
        for (ll i = 2; i <= n; i++) if (mark[i])
            if (limit >= d * Dist(point(xCur, yCur), a[i]) && cur < d * Dist(point(xCur, yCur), a[i]))
        {
            cur = d * Dist(point(xCur, yCur), a[i]);
            pos = i;
        }
        mark[pos] = false;
        limit = limit - d * Dist(point(xCur, yCur), a[pos]) + c[pos];
        xCur = a[pos].x; yCur = a[pos].y;
        if (pos == -1) return false;
        if (xCur == xDst && yCur == yDst) return true;
    }
    return true;
}

int main()
{
    //freopen("301B.INP", "r", stdin);
    //freopen("301B.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> d;
    for (ll i = 2; i < n; i++) cin >> c[i];
    cin >> xSrc >> ySrc;
    for (ll i = 2; i < n; i++)
        cin >> a[i].x >> a[i].y;
    cin >> xDst >> yDst;
    a[n] = point(xDst, yDst);
    //********************
    ll low = 0, high = 1e4;
    while (low <= high)
    {
        ll mid = (low + high) >> 1;
        if (Check(mid)) ans = mid, high = mid - 1;
        else low = mid + 1;
    }
    //********************
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll, ll> ii;
typedef pair <ll, ii> iii;

const ll N = 1e2 + 5;
const ll INF = 1e9 + 7;

struct point
{
    ll x, y;
    point (ll x, ll y) : x(x), y(y) {}
    point () {}
    inline friend ll Dist (const point &lhs, const point &rhs)
    {
        return abs(lhs.x - rhs.x) + abs(lhs.y - rhs.y);
    }
} a[N];

ll n, d, c[N], dp[N][N];

int main()
{
    //freopen("301B.INP", "r", stdin);
    //freopen("301B.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> d;
    for (ll i = 2; i < n; i++) cin >> c[i];
    for (ll i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
    //********************
    for (ll u = 1; u <= n; u++)
        for (ll v = 1; v <= n; v++)
            dp[u][v] = u == v ? 0 : Dist(a[u], a[v]) * d - c[v];
    for (ll k = 1; k <= n; k++)
        for (ll u = 1; u <= n; u++)
            for (ll v = 1; v <= n; v++)
                dp[u][v] = min(dp[u][v], dp[u][k] + dp[k][v]);
    //********************
    cout << dp[1][n];
    return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
int n,d;
int calc(pair<int,int> p1, pair<int,int> p2){
    return max((p1.first-p2.first),(p2.first-p1.first))+max((p1.second-p2.second),(p2.second-p1.second));
}
bool visited[101];
int A[101];
pair<int,int> C[101];
int main(){
    cin>>n>>d;
    priority_queue<pair<int,int> > pq;
    for(int i = 1; i < n-1; ++i){
        cin>>A[i];
    }
    for(int i = 0; i < n; ++i){
        cin>>C[i].first>>C[i].second;
    }
    int L =0, R = 400*d, mid, time, curr,weight;
    while(L < R){
        mid = time = (L+R)/2;
        curr = 0;
        for(int i = 1; i < n; ++i) {
            weight = d*calc(C[0],C[i]);
            if(time < weight) continue;
            pq.push(make_pair(time-weight+A[i],i));
        }
        while(!pq.empty()){
            while(!pq.empty() && visited[pq.top().second]) pq.pop();
            if(!pq.empty()){
                curr = pq.top().second;
                time = pq.top().first;
                for(int i = 1; i < n; ++i){
                    weight= d*calc(C[curr],C[i]);
                    if(curr==i||time<weight)continue;
                    pq.push(make_pair(time-weight+A[i],i));
                }
                visited[curr]=true;
            }
        }
        if(!visited[n-1]) L = mid+1;
        else R = mid;
        memset(visited,0,sizeof(visited));
    }
    cout << mid << endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
int n,d;
int calc(pair<int,int> p1, pair<int,int> p2){
    return max((p1.first-p2.first),(p2.first-p1.first))+max((p1.second-p2.second),(p2.second-p1.second));
}
bool visited[101];
int A[101];
pair<int,int> C[101];
int main(){
    cin>>n>>d;
    priority_queue<pair<int,int> > pq;
    for(int i = 1; i < n-1; ++i){
        cin>>A[i];
    }
    for(int i = 0; i < n; ++i){
        cin>>C[i].first>>C[i].second;
    }
    int L =0, R = 400*d, mid, time, curr,weight;
    while(L < R){
        mid = time = (L+R)/2;
        curr = 0;
        for(int i = 1; i < n; ++i) {
            weight = d*calc(C[0],C[i]);
            if(time < weight) continue;
            pq.push(make_pair(time-weight+A[i],i));
        }
        while(!pq.empty()){
            while(!pq.empty() && visited[pq.top().second]) pq.pop();
            if(!pq.empty()){
                curr = pq.top().second;
                time = pq.top().first;
                for(int i = 1; i < n; ++i){
                    weight= d*calc(C[curr],C[i]);
                    if(curr==i||time<weight)continue;
                    pq.push(make_pair(time-weight+A[i],i));
                }
                visited[curr]=true;
            }
        }
        if(!visited[n-1]) L = mid+1;
        else R = mid;
        memset(visited,0,sizeof(visited));
    }
    cout << L << endl;
}


#include <iostream>
#include <queue>
#include <string.h>
using namespace std;
queue <int> q;
struct puncte{
    int x,y;
}pct[105];
int timp[105],inq[105],n,d,a[105];
int dist(int i,int j)
{
    int dis1=pct[i].x-pct[j].x;
    int dis2=pct[i].y-pct[j].y;
    if(dis1<0)
        dis1=-dis1;
    if(dis2<0)
        dis2=-dis2;
    return dis1+dis2;
}
int BF()
{
    int dis,x;
    q.push(1);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        inq[x]=0;
        for(int i=2;i<n;i++)
        {
            if(i!=x)
            {
                dis=dist(i,x);
                if(dis<timp[x])
                {
                    timp[i]=max(timp[i],timp[x]-dis*d+a[i]);
                    if(inq[i]==0)
                    {
                        q.push(i);
                        inq[i]=1;
                    }
                }
            }
        }
        dis=dist(x,n);
        if(dis<timp[x])
            timp[n]=max(timp[n],timp[x]-dis*d);
    }
    if(timp[n]>0)
        return 1;
    return 0;
}
int main()
{
    int i,st,dr,mij;
    cin>>n>>d;
    for(i=2;i<n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        cin>>pct[i].x>>pct[i].y;
    st=0;dr=100000000;
    while(st<dr)
    {
        memset(timp+1,0,sizeof(timp)-1);
        mij=(st+dr)/2;
        timp[1]=mij;
        if(BF()==1)
            dr=mij-1;
        else
            st=mij+1;
    }
    cout<<dr;
    return 0;
}


#include <iostream>
#include <queue>
#include <string.h>
using namespace std;
queue <int> q;
struct puncte{
    int x,y;
}pct[105];
int timp[105],inq[105],n,d,a[105];
int dist(int i,int j)
{
    int dis1=pct[i].x-pct[j].x;
    int dis2=pct[i].y-pct[j].y;
    if(dis1<0)
        dis1=-dis1;
    if(dis2<0)
        dis2=-dis2;
    return dis1+dis2;
}
int BF()
{
    int dis,x;
    q.push(1);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        inq[x]=0;
        for(int i=2;i<n;i++)
        {
            if(i!=x)
            {
                dis=dist(i,x);
                if(dis<timp[x])
                {
                    if(timp[i]<timp[x]-dis*d+a[i])
                    {
                       timp[i]=timp[x]-dis*d+a[i];
                        if(inq[i]==0)
                        {
                            q.push(i);
                            inq[i]=1;
                        }
                    }
                }
            }
        }
        dis=dist(x,n);
        if(dis<timp[x])
            timp[n]=max(timp[n],timp[x]-dis*d);
    }
    if(timp[n]>0)
        return 1;
    return 0;
}
int main()
{
    int i,st,dr,mij;
    cin>>n>>d;
    for(i=2;i<n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        cin>>pct[i].x>>pct[i].y;
    st=0;dr=100000000;
    while(st<dr)
    {
        memset(timp+1,0,sizeof(timp)-1);
        mij=(st+dr)/2;
        timp[1]=mij;
        if(BF()==1)
            {
                if(dr==mij)
                    break;
                dr=mij;
            }
        else
            {
                if(st==mij)
                        break;
                st=mij;
            }
    }
    cout<<st;
    return 0;
}


#include <iostream>
#include <queue>
#include <string.h>
using namespace std;
queue <int> q;
struct puncte{
    int x,y;
}pct[105];
int timp[105],inq[105],n,d,a[105];
int dist(int i,int j)
{
    int dis1=pct[i].x-pct[j].x;
    int dis2=pct[i].y-pct[j].y;
    if(dis1<0)
        dis1=-dis1;
    if(dis2<0)
        dis2=-dis2;
    return dis1+dis2;
}
int BF()
{
    int dis,x;
    q.push(1);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        inq[x]=0;
        for(int i=2;i<n;i++)
        {
            if(i!=x)
            {
                dis=dist(i,x);
                if(dis<timp[x])
                {
                    if(timp[i]<timp[x]-dis*d+a[i])
                    {
                       timp[i]=timp[x]-dis*d+a[i];
                        if(inq[i]==0)
                        {
                            q.push(i);
                            inq[i]=1;
                        }
                    }
                }
            }
        }
        dis=dist(x,n);
        if(dis<timp[x])
            timp[n]=max(timp[n],timp[x]-dis*d);
    }
    if(timp[n]>0)
        return 1;
    return 0;
}
int main()
{
    int i,st,dr,mij;
    cin>>n>>d;
    for(i=2;i<n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        cin>>pct[i].x>>pct[i].y;
    st=0;dr=100000000;
    while(st<dr)
    {
        memset(timp+1,0,sizeof(timp)-1);
        mij=(st+dr)/2;
        timp[1]=mij;
        if(BF()==1)
            dr=mij-1;
        else
            st=mij+1;
    }
    cout<<dr;
    return 0;
}


#include <stdio.h>
#include <cmath>
using namespace std;

int mn(int a, int b)
{
  if(a != -1 && b != -1) return a < b ? a : b;
  if(a != -1) return a;
  return b;
}

int dist()
{

}

int main()
{
  int N, D;
  scanf("%d%d", &N, &D);
  int w[N];
  w[0] = w[N-1] = 0;
  for(int i=1; i<N-1; i++) scanf("%d", &w[i]);

  int nodes[N][2];
  for(int i=0; i<N; i++) scanf("%d%d", &nodes[i][0], &nodes[i][1]);

  int dp[N][N];
  for(int i=0; i<N; i++)
   for(int j=0; j<N; j++)
   {
     if(i == j)
      dp[i][j] = 0;
     else
      dp[i][j] = (abs(nodes[i][0] - nodes[j][0]) + abs(nodes[i][1] - nodes[j][1])) * D - w[i];
   }

  //floyd-warshall
  for(int k=0; k<N; k++)
   for(int i=0; i<N; i++)
    for(int j=0; j<N; j++)
     if(i != j && k != j && i != k)
      dp[i][j] = mn(dp[i][j], dp[i][k] + dp[k][j]);

  printf("%d", dp[0][N-1]);
  return 0;
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 150, inf = 1e9 + 7;
int n, d, a[N], dis[N][N], x[N], y[N];

int main() {
	cin >> n >> d;
	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)
				dis[i][j] = 0;
			else
				dis[i][j] = d * (abs(x[i] - x[j]) + abs(y[i] - y[j])) - a[j];
		}
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]);
	cout << dis[0][n - 1] << "\n";
}


#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
int n;
long long D;
const int sz=105;
int x[sz];
int y[sz];
bool visited[sz];
int a[sz];
long long d[sz];

void dijkstra(){
    d[n]=0;
    priority_queue<pair<int,int>> q;
    q.push({d[n],n});
    while(!q.empty()){
        int curr=q.top().Y;
        q.pop();
        visited[curr]=1;
        for(int i=1;i<=n;i++){
            if(i==curr) continue;
            if(visited[i]) continue;
            long long nd=d[curr]+D*(abs(x[i]-x[curr])+abs(y[i]-y[curr]))-a[i];
            if(nd<d[i]){
                d[i]=nd;
                q.push({-d[i],i});
            }
        }
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %I64d",&n,&D);
    for(int i=2;i<=n-1;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d %d",&x[i],&y[i]);
    for(int i=1;i<=n;i++) d[i]=1e18;
    dijkstra();
    printf("%I64d",d[1]);
    return 0;
}
//hello


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define eps 1e-10
#define fi first
#define se second
#define MOD1 1000000007LL
#define MOD 1000000009LL
#define p1 53
#define se second
#define INF 2000000000000000000LL
#define pb push_back

int gcd1(int a, int b) {
    if (a == 0)
        return b;
    return gcd1(b % a, a);
}

ll modx(ll base, ll ex)
{
    ll ans = 1LL, val = base;
    while(ex > 0LL)
    {
        if(ex&1LL)
            ans = (ans*val)%MOD;
        val = (val*val)%MOD;
        ex = ex>>1LL;
    }
    return ans;
}

int n, d, x, y;
const int maxn = 105;
int a[maxn];
int dist[maxn][maxn];
vector <pair<int,int> > v;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("B1.in", "r", stdin);

    cin >> n >> d;

    for(int i=2; i<n; i++)
        cin >> a[i];

    for(int i=1; i<=n; i++){
        cin >> x >> y;
        v.pb(make_pair(x,y));
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j)
                continue;

            dist[i+1][j+1] = d*(abs(v[i].first - v[j].first) + abs(v[i].second - v[j].second)) - a[i+1];
        }
    }

    //cout << dist[1][2] << " " << dist[2][3] << endl;
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++)
                dist[i][j] = min(dist[i][j], max(dist[i][k], max(dist[k][j],dist[i][k] + dist[k][j])));
        }
    }

    cout << max(0,dist[1][n]) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define eps 1e-10
#define fi first
#define se second
#define MOD1 1000000007LL
#define MOD 1000000009LL
#define p1 53
#define se second
#define INF 2000000000000000000LL
#define pb push_back

int gcd1(int a, int b) {
    if (a == 0)
        return b;
    return gcd1(b % a, a);
}

ll modx(ll base, ll ex)
{
    ll ans = 1LL, val = base;
    while(ex > 0LL)
    {
        if(ex&1LL)
            ans = (ans*val)%MOD;
        val = (val*val)%MOD;
        ex = ex>>1LL;
    }
    return ans;
}

int n, d, x, y;
const int maxn = 105;
int a[maxn];
int dist[maxn][maxn];
vector <pair<int,int> > v;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("B1.in", "r", stdin);

    cin >> n >> d;

    for(int i=2; i<n; i++)
        cin >> a[i];

    for(int i=1; i<=n; i++){
        cin >> x >> y;
        v.pb(make_pair(x,y));
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j)
                continue;

            dist[i+1][j+1] = d*(abs(v[i].first - v[j].first) + abs(v[i].second - v[j].second)) - a[i+1];
        }
    }

    //cout << dist[1][2] << " " << dist[2][3] << endl;
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    }

    cout << max(0,dist[1][n]) << endl;

    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std;
#define N 105
#define D 100005
int vis[N];
int head[N];
int next1[N];
int ver[N];
int quan[N];
int d[N];
int a[N];
queue<int> q;
int tot;
struct zuobiao
{
	int x,y;
}w[N];
void add(int x,int y,int z )
{
	ver[++tot]=y;
	quan[tot]=z;
	next1[tot]=head[x];
	head[x]=tot;
}
void sp(int p)
{
	memset(d,10000,sizeof(d));
	memset(vis,0,sizeof(vis));
	d[p]=0;
	q.push(p);
	vis[p]=1;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		vis[x]=0;
		for(int i=head[x];i;i=next1[i])
		{
			int y=ver[i];
			if(d[y]>d[x]+quan[i])
		{
			d[y]=d[x]+quan[i];
			if(!vis[y])
			{
			vis[y]=1;
			q.push(y);
			}
		}
		}
	}
}
void init()
{
	memset(head,0,sizeof(head));
	memset(next1,0,sizeof(next1));
	memset(ver,0,sizeof(ver));
	memset(quan,0,sizeof(quan));
}
int main()
{
	int n,dit;
	while(~scanf("%d%d",&n,&dit))
	{
		init();
		tot=0;
		for(int i=2;i<=n-1;i++)
		scanf("%d",&a[i]);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i].x,&w[i].y);
	    }
	    int sum=0;
		for(int i=1;i<=n-1;i++)
		{
			sum+=a[i+1];
			if((abs(w[i].x-w[i+1].x)+abs(w[i].y-w[i+1].y))*dit-sum<0)
			{
			add(i,i+1,0);
			sum-=(abs(w[i].x-w[i+1].x)+abs(w[i].y-w[i+1].y))*dit;
		    }
			else
			{
			add(i,i+1,(abs(w[i].x-w[i+1].x)+abs(w[i].y-w[i+1].y))*dit-sum);
			sum-=a[i+1];
		    }
		}
	    sp(1);
	    printf("%d\n",d[n]);

	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std;
#define N 105
#define D 100005
int d[N][N];
int a[N];
struct zuobiao
{
	int x,y;
}w[N];
int main()
{
	int n,dit;
	while(~scanf("%d%d",&n,&dit))
	{
		memset(d,0x3f,sizeof(d));
		memset(a,0,sizeof(a));
		for(int i=2;i<=n-1;i++)
		scanf("%d",&a[i]);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i].x,&w[i].y);
	    }
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
			   d[i][j]=min(((abs(w[i].x-w[j].x)+abs(w[i].y-w[j].y))*dit-a[j]),d[i][j]);
		    }
		}
		for(int i=1;i<=n;i++)
		{
			d[i][i]=0;
		}
		   for(int k=1;k<=n;k++)
		   {
				for(int i=1;i<=n;i++)
		      {
				    for(int j=1;j<=n;j++)
		            {
		     	          d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		            }
		      }
		    }
		  		printf("%d\n",d[1][n]);
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std;
#define N 105
#define D 100005
int d[N][N];
int a[N];
struct zuobiao
{
	int x,y;
}w[N];
int main()
{
	int n,dit;
	while(~scanf("%d%d",&n,&dit))
	{
		memset(d,0x3f,sizeof(d));
		for(int i=2;i<=n-1;i++)
		scanf("%d",&a[i]);
		for(int i=1;i<=n;i++)
		{
			d[i][i]=0;
		}
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i].x,&w[i].y);
	    }
		for(int i=1;i<=n;i++)
		{
			for(int j=i;j<=n;j++)
			{
			   d[i][j]=min(((abs(w[i].x-w[j].x)+abs(w[i].y-w[j].y))*dit-a[j]),d[i][j]);
		    }
		}
		   for(int k=1;k<=n;k++)
		   {
				for(int i=1;i<=n;i++)
		      {
				    for(int j=1;j<=n;j++)
		            {
		     	          d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		            }
		      }
		    }
		  		printf("%d\n",d[1][n]);
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std;
#define N 105
#define D 100005
int d[N][N];
int a[N];
struct zuobiao
{
	int x,y;
}w[N];
int main()
{
	int n,dit;
	while(~scanf("%d%d",&n,&dit))
	{
		memset(d,0x3f,sizeof(d));
		memset(a,0,sizeof(a));
		for(int i=2;i<=n-1;i++)
		scanf("%d",&a[i]);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i].x,&w[i].y);
	    }
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
			   d[i][j]=min(((abs(w[i].x-w[j].x)+abs(w[i].y-w[j].y))*dit-a[j]),d[i][j]);
		    }
		}
		for(int i=1;i<=n;i++)
		{
			d[i][i]=0;
		}
		   for(int k=1;k<=n;k++)
		   {
				for(int i=1;i<=n;i++)
		      {
				    for(int j=1;j<=n;j++)
		            {
		     	          d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		            }
		      }
		    }
		  		printf("%d\n",d[1][n]);
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std;
#define N 105
#define D 100005
int d[N][N];
int a[N];
struct zuobiao
{
	int x,y;
}w[N];
int main()
{
	int n,dit;
	while(~scanf("%d%d",&n,&dit))
	{
		memset(d,0x3f,sizeof(d));
		for(int i=2;i<=n-1;i++)
		scanf("%d",&a[i]);
		for(int i=1;i<=n;i++)
		{
			d[i][i]=0;
		}
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i].x,&w[i].y);
	    }
	    int sum=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
			   d[i][j]=min(((abs(w[i].x-w[j].x)+abs(w[i].y-w[j].y))*dit-a[j+1]),d[i][j]);
		    }
		}
		  		printf("%d\n",d[1][n]);
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<sstream>
#include<cmath>
using namespace std;
#define N 105
#define D 100005
int d[N][N];
int a[N];
struct zuobiao
{
	int x,y;
}w[N];
int main()
{
	int n,dit;
	while(~scanf("%d%d",&n,&dit))
	{
		memset(d,0x3f,sizeof(d));
		for(int i=2;i<=n-1;i++)
		scanf("%d",&a[i]);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&w[i].x,&w[i].y);
	    }
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
			   d[i][j]=min(((abs(w[i].x-w[j].x)+abs(w[i].y-w[j].y))*dit-a[j]),d[i][j]);
		    }
		}
		for(int i=1;i<=n;i++)
		{
			d[i][i]=0;
		}
		   for(int k=1;k<=n;k++)
		   {
				for(int i=1;i<=n;i++)
		      {
				    for(int j=1;j<=n;j++)
		            {
		     	          d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		            }
		      }
		    }
		  		printf("%d\n",d[1][n]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main()
{
	LL T,N,D,i,j,k,temp,tempx,tempy;
	//cin>>T;
	//while(T--)
	//{
		cin>>N>>D;
		vector<LL> A;
		A.push_back(0);
		for(i=0;i<N-2;i++)
		{
			cin>>temp;
			A.push_back(temp);
		}
		vector<LL> x;
		vector<LL> y;
		for(i=0;i<N;i++)
		{
			cin>>tempx>>tempy;
			x.push_back(tempx);
			y.push_back(tempy);
		}
		vector<vector<LL> > DP;
		for(i=0;i<=200;i++)
		{
			vector<LL> t;
			for(j=0;j<=200;j++)
				t.push_back(0);
			DP.push_back(t);
		}
		for(i=0;i<N;i++)
		{
			for(j=0;j<N;j++)
			{
				if(i!=j)
					DP[i][j]=(abs(x[i]-x[j])+abs(y[i]-y[j]))*D-A[i];
			}
		}
		for(k=0;k<N;k++)
		{
			for(i=0;i<N;i++)
			{
				for(j=0;j<N;j++)
					DP[i][j]=min(DP[i][j],DP[i][k]+DP[k][j]);
			}
		}
		cout<<DP[0][N-1]<<"\n";
//	}
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    while(cin>>n>>m){
        vi ps(n+1); fore(i,1,n+1) cin>>ps[i];

        int l,r,x;
        while(m--){
            cin>>l>>r>>x;
            vi np(ps.begin()+l, ps.begin()+r+1);
            // sort(all(np));
            nth_element(np.begin(), np.begin()+x-l, np.end());
            // deb(l,r);
            // print(np);
            bool yes = (np[x-l]==ps[x]);
            cout<<(yes ? "Yes\n" : "No\n");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    while(cin>>n>>m){
        vi ps(n+1); fore(i,1,n+1) cin>>ps[i];

        int l,r,x;
        while(m--){
            cin>>l>>r>>x;
            vi np(ps.begin()+l, ps.begin()+r+1);
            sort(all(np));
            // deb(l,r);
            // print(np);
            bool yes = (np[x-l]==ps[x]);
            cout<<(yes ? "Yes\n" : "No\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m, l, r, x; cin >> n >> m;
    int a[n]; for(int &i : a) cin >> i;

    while(m--) {
        vector<int> v;
        cin >> l >> r >> x;
        int tmp = a[x-1];
        int ind = x - l;
        for(int i = l-1; i < r; i++) v.push_back(a[i]);
        sort(v.begin(), v.end());
        int p = lower_bound(v.begin(), v.end(), tmp) - v.begin();

        if(p != ind && l != r) cout << "No";
        else cout << "Yes";
        cout << '\n';
    }
}


#include<bits/stdc++.h>
using namespace std;

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m, l, r, x; cin >> n >> m;
    int a[n]; for(int &i : a) cin >> i;

    while(m--) {
        vector<int> v;
        cin >> l >> r >> x;
        int ind = x - l;
        for(int i = l-1; i < r; i++) v.push_back(a[i]);
        sort(v.begin(), v.end());
        int p = lower_bound(v.begin(), v.end(), a[x]) - v.begin();

        if(p != ind-1 && l != r) cout << "No";
        else cout << "Yes";
        cout << '\n';
    }
}


#include<bits/stdc++.h>
using namespace std;

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m, l, r, x; cin >> n >> m;
    int a[n]; for(int &i : a) cin >> i;

    while(m--) {
        vector<int> v;
        cin >> l >> r >> x;
        int tmp = a[x-1];
        int ind = x - l, cnt = 0;
        for(int i = l-1; i < r; i++) if(a[i] < tmp) cnt++;
        cout << (cnt == ind ? "Yes" : "No") << '\n';
    }
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define f(i, n) for (int i = 0; i < int(n); i++)
#define g(i, n) for (int i = 0; i < int(n-1); i++)
#define fj(j, n) for (int j = 0; j < int(n); j++)
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

// Driver function to sort the vector elements by
// second element of pair in descending order
bool sortbysecdesc(const pair<int,int> &a,
                   const pair<int,int> &b)
{
       return a.second>b.second;
}

// Driver function to sort the vector elements by
// first element of pair in descending order
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

// Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

//Function to return lcm of a and b
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

// Function to find gcd of array of
// numbers
int findGCD(ll a[], ll n)
{
    int result = a[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(a[i], result);

        if(result == 1)
        {
           return 1;
        }
    }
    return result;
}

int32_t main() {
    fio;

    ll n,m,p,q,r,count=0;
    cin>>n>>m;
    vll a(n+1),b(n);
    for(int i=1;i<=n;i++)
    {
    cin>>a[i];
    b[i]=a[i];
    }
    // sort(b.begin(),b.end());
    for(int j=1;j<=m;j++)
    {
        cin>>p>>q>>r;
        count=0;
        for(int i=p;i<=q;i++)
        {
            if(a[i]<a[r])
            count++;

        }
        if(p+count==r)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;

    }

    return 0 ;

}