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 CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
enum SegType { SUM, MIN, MAX };
template <typename T>
struct SegTree {
  int num = 0, bt;
  vector<T> node, lazy;
  typedef function<T(const T &, const T &)> c1t;
  typedef function<T(const T &, const int &, const int &, const int &,
                     const int &, const T &)>
      c2t;
  typedef function<T(const T &, const T &)> c3t;
  c1t calc1;
  c2t calc2;
  c3t calc3;
  T _init;
  void init(int num, T n, c1t calc1, c2t calc2, c3t calc3) {
    int i = 0, j = 1;
    this->num = num;
    this->_init = n;
    this->calc1 = calc1;
    this->calc2 = calc2;
    this->calc3 = calc3;
    for (j = 1; j < num;) j *= 2;
    this->bt = j - 1;
    node.resize(j * 2 - 1, n);
    lazy.resize(j * 2 - 1, 0);
  }
  void init(int num, T n, SegType st) {
    if (st == SegType::MAX) {
      if (std::is_same<T, int>().value)
        _init = (T)INT_MIN;
      else if (std::is_same<T, long long>().value)
        _init = (T)LLONG_MIN;
      else
        _init = (T)n;
      init(
          num, n, [](const T &a, const T &b) { return max(a, b); },
          [](const T &a, const int &x, const int &y, const int &l, const int &r,
             const T &n) { return a + n; },
          [](const T &a, const T &n) { return a + n; });
    } else if (st == SegType::MIN) {
      if (std::is_same<T, int>().value)
        _init = (T)INT_MAX;
      else if (std::is_same<T, long long>().value)
        _init = (T)LLONG_MAX;
      else
        _init = (T)n;
      init(
          num, n, [](const T &a, const T &b) { return min(a, b); },
          [](const T &a, const int &x, const int &y, const int &l, const int &r,
             const T &n) { return a + n; },
          [](const T &a, const T &n) { return a + n; });
    } else if (st == SegType::SUM) {
      if (std::is_same<T, int>().value)
        _init = (T)0;
      else if (std::is_same<T, long long>().value)
        _init = (T)0;
      else
        _init = (T)n;
      init(
          num, n, [](const T &a, const T &b) { return (a + b); },
          [](const T &a, const int &x, const int &y, const int &l, const int &r,
             const T &n) { return (a + (r - l + 1) * n); },
          [](const T &a, const T &n) { return (a + n / 2); });
    }
  }
  void addd(int x, int y, T n) {
    if (x > y) return;
    _addd(x, y, n, 0, 0, this->bt);
  }
  void _addd(const int &x, const int &y, const T &n, int p, int l, int r) {
    if (r < x || y < l) return;
    if (x <= l && r <= y) {
      lazy[p] = calc2(lazy[p], x, y, l, r, n);
      evall(p);
    } else {
      if (lazy[p] != 0) evall(p);
      _addd(x, y, n, p * 2 + 1, l, (l + r) / 2);
      _addd(x, y, n, p * 2 + 2, (l + r) / 2 + 1, r);
      node[p] = calc1(node[p * 2 + 1], node[p * 2 + 2]);
    }
  }
  inline void evall(int x) {
    node[x] += lazy[x];
    if (x < bt) {
      lazy[x * 2 + 1] = calc3(lazy[x * 2 + 1], lazy[x]);
      lazy[x * 2 + 2] = calc3(lazy[x * 2 + 2], lazy[x]);
    }
    lazy[x] = 0;
  }
  void sett(int x, T n) {
    gett(x);
    int i = bt + x;
    node[i] = n;
    while (i != 0) {
      i = (i - 1) / 2;
      node[i] = calc1(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  inline T gett(int x) {
    T ret = _init;
    _gett(x, x, 0, 0, this->bt, ret);
    return ret;
  }
  T gett(int x, int y) {
    T ret = _init;
    if (x > y) return ret;
    _gett(x, y, 0, 0, this->bt, ret);
    return ret;
  }
  void _gett(const int &x, const int &y, int p, int l, int r, T &ret) {
    if (r < x || y < l) return;
    if (lazy[p] != 0) evall(p);
    if (x <= l && r <= y) {
      ret = calc1(ret, node[p]);
      return;
    }
    _gett(x, y, p * 2 + 1, l, (l + r) / 2, ret);
    _gett(x, y, p * 2 + 2, (l + r) / 2 + 1, r, ret);
  }
};
long long N, A[505050], P[505050], M, B[505050];
long long i, j, k;
int main() {
  scanf("%lld", &N);
  for (i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  for (i = 0; i < N; ++i) {
    scanf("%lld", &P[i]);
  }
  scanf("%lld", &M);
  for (i = 0; i < M; ++i) {
    scanf("%lld", &B[i + 1]);
  }
  SegTree<long long> dp;
  dp.init(M + 5, (long long)(1e18), SegType::MIN);
  dp.sett(0, 0);
  for (i = 0; i < N; ++i) {
    long long bi = lower_bound(B, B + M + 1, A[i]) - B;
    if (P[i] < 0) {
      if (A[i] == B[bi] && dp.gett(bi - 1) < dp.gett(bi) + P[i]) {
        long long a = dp.gett(bi - 1);
        dp.addd(0, M + 1, P[i]);
        dp.sett(bi, a);
      } else {
        dp.addd(0, M + 1, P[i]);
      }
    } else {
      if (A[i] == B[bi] && dp.gett(bi - 1) < dp.gett(bi)) {
        long long a = dp.gett(bi - 1);
        dp.addd(0, bi - 1, P[i]);
        dp.sett(bi, a);
      } else {
        dp.addd(0, bi - 1, P[i]);
      }
    }
  }
  if (dp.gett(M) > 1e17) {
    printf("NO\n");
  } else {
    printf("YES\n%lld\n", dp.gett(M));
  }
  return 0;
}