Problem: Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i to the end of the resulting array if it is greater than all previous elements (more formally, if a_i > max_{1 ≤ j < i}a_j). Some examples of the function f:

  1. if a = [3, 1, 2, 7, 7, 3, 6, 7, 8] then f(a) = [3, 7, 8]; 
  2. if a = [1] then f(a) = [1]; 
  3. if a = [4, 1, 1, 2, 3] then f(a) = [4]; 
  4. if a = [1, 3, 1, 2, 6, 8, 7, 7, 4, 11, 10] then f(a) = [1, 3, 6, 8, 11]. 



You are given two arrays: array a_1, a_2, ... , a_n and array b_1, b_2, ... , b_m. You can delete some elements of array a (possibly zero). To delete the element a_i, you have to pay p_i coins (the value of p_i can be negative, then you get |p_i| coins, if you delete this element). Calculate the minimum number of coins (possibly negative) you have to spend for fulfilling equality f(a) = b.

Input

The first line contains one integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the length of array a.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the array a.

The third line contains n integers p_1, p_2, ..., p_n (|p_i| ≤ 10^9) — the array p.

The fourth line contains one integer m (1 ≤ m ≤ n) — the length of array b.

The fifth line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ n, b_{i-1} < b_i) — the array b.

Output

If the answer exists, in the first line print YES. In the second line, print the minimum number of coins you have to spend for fulfilling equality f(a) = b.

Otherwise in only line print NO.

Examples

Input


11
4 1 3 3 7 8 7 9 10 7 11
3 5 0 -2 5 3 6 7 8 2 4
3
3 7 10


Output


YES
20


Input


6
2 1 5 3 6 5
3 -9 0 16 22 -14
4
2 3 5 6


Output


NO

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

/*
procrastinating
*/

public class Main {

    static FastReader in;
    static PrintWriter out;
    static Random rand = new Random();
    static final int INF = (int) (1e9 + 10), MOD = (int) (998244353), LOGN = 60;
    static final long IINF = (long) (2e18 + 10);

    static class SegTree {
        int sz;
        long[] max, add;

        void build(int arr_sz) {
            sz = 1;
            while (sz < arr_sz) sz *= 2;
            max = new long[sz * 2 - 1]; Arrays.fill(max, IINF);
            add = new long[sz * 2 - 1];
        }

        void push(int v) {
            if (add[v] != 0) {
                max[v * 2 + 1] += add[v];
                add[v * 2 + 1] += add[v];
                max[v * 2 + 2] += add[v];
                add[v * 2 + 2] += add[v];
                add[v] = 0;
            }
        }
        void pull(int v) {
            max[v] = Math.max(max[v * 2 + 1], max[v * 2 + 2]);
        }

        long get(int v, int tl, int tr, int i) {
            if (tl == tr) {
                return max[v];
            }
            int tm = (tl + tr) / 2;
            push(v);
            if (i <= tm) {
                return get(v * 2 + 1, tl, tm, i);
            } else {
                return get(v * 2 + 2, tm + 1, tr, i);
            }
        }
        long get(int i) {
            return get(0, 0, sz - 1, i);
        }

        void set(int v, int tl, int tr, int i, long val) {
            if (tl == tr) {
                max[v] = val;
                return;
            }
            int tm = (tl + tr) / 2;
            push(v);
            if (i <= tm) {
                set(v * 2 + 1, tl, tm, i, val);
            } else {
                set(v * 2 + 2, tm + 1, tr, i, val);
            }
            pull(v);
        }
        void set(int i, long val) {
            set(0, 0, sz - 1, i, val);
        }

        void addOn(int v, int tl, int tr, int l, int r, long val) {
            if (r < tl || l > tr) return;
            if (l <= tl && tr <= r) {
                max[v] += val;
                add[v] += val;
                return;
            }
            int tm = (tl + tr) / 2;
            push(v);
            addOn(v * 2 + 1, tl, tm, l, r, val);
            addOn(v * 2 + 2, tm + 1, tr, l, r, val);
            pull(v);
        }
        void addOn(int l, int r, long val) {
            addOn(0, 0, sz - 1, l, r, val);
        }
    }

    static int lower(int[] arr, int x) {
        int l = 0, r = arr.length;
        while (l < r) {
            int m = (l + r) / 2;
            if (arr[m] < x) {
                l = m + 1;
            } else {
                r = m;
            }
        }
        return l;
    }

    static void solve() {
        int n = in.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        long[] p = new long[n];
        for (int i = 0; i < n; i++)
            p[i] = in.nextInt();

        int m = in.nextInt();

        int[] b = new int[m];
        int[] pos = new int[n + 1]; Arrays.fill(pos, -1);
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
            pos[b[i]] = i + 1;
        }

        SegTree dp = new SegTree();
        dp.build(m + 1);
        dp.set(0, 0);
        int last = 0;
        for (int i = 0; i < n; i++) {
            if (pos[a[i]] == -1) {
                if (p[i] < 0) {
                    dp.addOn(0, last, p[i]);
                } else {
                    int j = lower(b, a[i]) + 1;
                    dp.addOn(0, Math.min(last, j - 1), p[i]);
                }
            } else {
                if (last < pos[a[i]] - 1) {
                    dp.addOn(0, last, p[i]);
                } else if (last == pos[a[i]] - 1) {
                    long val = dp.get(pos[a[i]] - 1);
                    dp.set(pos[a[i]], val);
                    dp.addOn(0, last, p[i]);
                    last++;
                } else {
                    long val1 = dp.get(pos[a[i]] - 1);
                    long val2 = dp.get(pos[a[i]]);
                    if (p[i] < 0) {
                        dp.set(pos[a[i]], Math.min(val1, val2 + p[i]));
                        dp.addOn(0, pos[a[i]] - 1, p[i]);
                        dp.addOn(pos[a[i]] + 1, last, p[i]);
                    } else {
                        dp.set(pos[a[i]], Math.min(val1, val2));
                        dp.addOn(0, pos[a[i]] - 1, p[i]);
                    }
                }
            }
        }

        if (last < m) {
            out.println("NO");
        } else {
            out.println("YES");
            long val = dp.get(m);
            out.println(val);
        }
    }

    public static void main(String[] args) throws FileNotFoundException, InterruptedException {
        in = new FastReader(System.in);
//        in = new FastReader(new FileInputStream("input.txt"));
        out = new PrintWriter(System.out);
//        out = new PrintWriter(new FileOutputStream("output.txt"));

        Thread thread = new Thread(null, () -> {
            int tests = 1;
//            tests = in.nextInt();

            while (tests-- > 0) {
                solve();
            }
        }, "Go", 1 << 28);
        thread.start();
        thread.join();

//        out.flush();
        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

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

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

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine());
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}