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>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename num_t>
struct segtree {
  int n, depth;
  vector<num_t> tree, lazy;
  void init(int second, long long* arr) {
    n = second;
    tree = vector<num_t>(4 * second, 0);
    lazy = vector<num_t>(4 * second, 0);
    init(0, 0, n - 1, arr);
  }
  num_t init(int i, int l, int r, long long* arr) {
    if (l == r) return tree[i] = arr[l];
    int mid = (l + r) / 2;
    num_t a = init(2 * i + 1, l, mid, arr),
          b = init(2 * i + 2, mid + 1, r, arr);
    return tree[i] = a.op(b);
  }
  void update(int l, int r, num_t v) {
    if (l > r) return;
    update(0, 0, n - 1, l, r, v);
  }
  num_t update(int i, int tl, int tr, int ql, int qr, num_t v) {
    eval_lazy(i, tl, tr);
    if (tl > tr || tr < ql || qr < tl) return tree[i];
    if (ql <= tl && tr <= qr) {
      lazy[i] = lazy[i].val + v.val;
      eval_lazy(i, tl, tr);
      return tree[i];
    }
    if (tl == tr) return tree[i];
    int mid = (tl + tr) / 2;
    num_t a = update(2 * i + 1, tl, mid, ql, qr, v),
          b = update(2 * i + 2, mid + 1, tr, ql, qr, v);
    return tree[i] = a.op(b);
  }
  num_t query(int l, int r) {
    if (l > r) return num_t::null_v;
    return query(0, 0, n - 1, l, r);
  }
  num_t query(int i, int tl, int tr, int ql, int qr) {
    eval_lazy(i, tl, tr);
    if (ql <= tl && tr <= qr) return tree[i];
    if (tl > tr || tr < ql || qr < tl) return num_t::null_v;
    int mid = (tl + tr) / 2;
    num_t a = query(2 * i + 1, tl, mid, ql, qr),
          b = query(2 * i + 2, mid + 1, tr, ql, qr);
    return a.op(b);
  }
  void eval_lazy(int i, int l, int r) {
    tree[i] = tree[i].lazy_op(lazy[i], (r - l + 1));
    if (l != r) {
      lazy[i * 2 + 1] = lazy[i].val + lazy[i * 2 + 1].val;
      lazy[i * 2 + 2] = lazy[i].val + lazy[i * 2 + 2].val;
    }
    lazy[i] = num_t();
  }
};
struct sum_t {
  long long val;
  static const long long null_v = 0;
  sum_t() : val(0) {}
  sum_t(long long v) : val(v) {}
  sum_t op(sum_t& other) { return sum_t(val + other.val); }
  sum_t lazy_op(sum_t v, int size) { return sum_t(val + v.val * size); }
};
const long double pi = 3.14159265358979323846;
const ll mod = 998244353;
ll a[500009], p[500009], b[500009], c[500009];
ll dp[500009];
segtree<sum_t> need;
pll ord[500009];
map<ll, vl> locs;
void solve() {
  ll n, k;
  a[0] = -1;
  p[0] = mod * mod;
  cin >> n;
  for (long long i = 0; i < (n); i++) {
    cin >> a[i + 1];
    --a[i + 1];
  }
  for (long long i = 0; i < (n); i++) cin >> p[i + 1];
  a[n + 1] = n;
  p[n + 1] = mod * mod;
  n += 2;
  b[0] = -1;
  cin >> k;
  for (long long i = 0; i < (k); i++) {
    cin >> b[i + 1];
    --b[i + 1];
  }
  b[k + 1] = n - 2;
  k += 2;
  need.init(n, p);
  for (long long i = 0; i < (n); i++) ord[i] = make_pair(a[i], i);
  sort(ord, ord + n);
  for (long long i = 0; i < (n); i++) locs[a[i]].push_back(i);
  int npt = 0;
  const ll SENT = 2 * mod * mod;
  for (long long i = 0; i < (n); i++) dp[i] = SENT;
  dp[0] = 0;
  for (long long i = (1); i < (k); i++) {
    while (npt < n && ord[npt].first <= b[i - 1]) {
      ll v = p[ord[npt].second];
      if (v > 0) {
        need.update(ord[npt].second, ord[npt].second, -v);
      }
      ++npt;
    }
    ll opt = 0;
    set<ll> best;
    ll off = 0;
    vl& x = locs[b[i]];
    vl& lst = locs[b[i - 1]];
    for (long long j = 0; j < (x.size()); j++) {
      while (opt < lst.size() && lst[opt] < x[j]) {
        ll ii = lst[opt];
        if (dp[ii] != SENT) {
          ll v = 0, i1 = ii + 1, i2 = x[j] - 1;
          if (i1 <= i2) v = need.query(i1, i2).val;
          best.insert(dp[ii] + v - off);
        }
        ++opt;
      }
      if (best.size()) {
        dp[x[j]] = *best.begin() + off;
      }
      ll nxt = 0;
      if (j != x.size() - 1) {
        ll i1 = x[j], i2 = x[j + 1] - 1;
        if (i1 <= i2) {
          nxt = need.query(i1, i2).val;
        }
      }
      off += nxt;
    }
  }
  if (dp[n - 1] == SENT) {
    cout << "NO\n";
  } else {
    cout << "YES\n" << dp[n - 1] << '\n';
  }
}
int main() {
  fio();
  int T;
  T = 1;
  while (T--) solve();
}