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;
int pct(int x) { return __builtin_popcount(x); }
int pct(long long x) { return __builtin_popcountll(x); }
int bit(int x) { return 31 - __builtin_clz(x); }
int bit(long long x) { return 63 - __builtin_clzll(x); }
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
long long cdiv(long long a, long long b) {
  return a / b + !(a < 0 || a % b == 0);
}
template <typename T>
void leftShift(vector<T> &v, long long k) {
  k %= (int)v.size();
  if (k < 0) k += (int)v.size();
  rotate(v.begin(), v.begin() + k, v.end());
}
template <typename T>
void rightSift(vector<T> &v, long long k) {
  leftShift(v, (int)v.size() - k);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
  uniform_int_distribution<long long> uid(l, r);
  return uid(rng);
}
inline int nxt() {
  int x;
  cin >> x;
  return x;
}
inline int nxtll() {
  long long x;
  cin >> x;
  return x;
}
void pr() {}
void sc() {}
template <typename Head, typename... Tail>
void pr(Head H, Tail... T) {
  cout << H << " ";
  pr(T...);
}
template <typename Head, typename... Tail>
void sc(Head &H, Tail &...T) {
  cin >> H;
  sc(T...);
}
string to_string(__int128 x) {
  string s = "";
  bool neg = 0;
  if (x < 0) {
    s += "-";
    neg = 1;
  }
  if (!x) s += '0';
  while (x) {
    int rem = x % 10;
    s += to_string(rem);
    x /= 10;
  }
  reverse(s.begin() + neg, s.end());
  return s;
}
const int mod = 1e9 + 7;
int pwr(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * 1LL * a) % mod;
    a = (a * 1LL * a) % mod;
    b >>= 1;
  }
  return ans;
}
template <typename T>
class Segtree_Without_Lazy {
  struct node {
    T val;
  };
  int n;
  vector<node> tr;
  T Id;
  inline T op(T a, T b) { return a + b; }
  inline node merge(node a, node b) {
    node ans;
    ans.val = op(a.val, b.val);
    return ans;
  }
  void build(int nd, int s, int e, const vector<T> &v) {
    if (s == e) {
      tr[nd].val = v[s];
      return;
    }
    int m = (s + e) >> 1;
    build(nd << 1, s, m, v);
    build(nd << 1 | 1, m + 1, e, v);
    tr[nd] = merge(tr[nd << 1], tr[nd << 1 | 1]);
  }
  void upd(int idx, T x, int nd, int s, int e) {
    if (s == e) {
      tr[nd].val = op(tr[nd].val, x);
      return;
    }
    int m = (s + e) >> 1;
    if (idx <= m)
      upd(idx, x, nd << 1, s, m);
    else
      upd(idx, x, nd << 1 | 1, m + 1, e);
    tr[nd] = merge(tr[nd << 1], tr[nd << 1 | 1]);
  }
  T query(int l, int r, int nd, int s, int e) {
    if (s > r || e < l) return Id;
    if (l <= s && e <= r) return tr[nd].val;
    int m = (s + e) >> 1;
    return op(query(l, r, nd << 1, s, m), query(l, r, nd << 1 | 1, m + 1, e));
  }
  void print(int l, int r, int nd, int s, int e, vector<T> &v) {
    if (s > r || e < l) return;
    if (s == e) {
      v.push_back(tr[nd].val);
      return;
    }
    int m = (s + e) >> 1;
    print(l, r, nd << 1, s, m, v);
    print(l, r, nd << 1 | 1, m + 1, e, v);
  }

 public:
  Segtree_Without_Lazy(int nn) : n(nn), Id(0), tr(4 * nn, {0}) {}
  Segtree_Without_Lazy(const vector<T> &v)
      : n((int)v.size() - 1), tr(4 * n), Id(0) {
    build(1, 1, n, v);
  }
  void upd(int idx, T val) {
    assert(1 <= idx && idx <= n);
    upd(idx, val, 1, 1, n);
  }
  T query(int l, int r) {
    if (l > r) return Id;
    assert(1 <= l && r <= n);
    return query(l, r, 1, 1, n);
  }
  void print(int l, int r) {
    vector<T> v;
    print(l, r, 1, 1, n, v);
    42;
  }
};
const int N = 5e5 + 5;
int a[N], p[N], b[N];
int in[N];
long long dp[N];
void solve() {
  int n;
  sc(n);
  for (int i = 1; i <= n; i++) {
    sc(a[i + 1]);
    a[i + 1]++;
  }
  for (int i = 1; i <= n; i++) {
    sc(p[i + 1]);
  }
  a[1] = 1;
  n++;
  int m;
  sc(m);
  for (int i = 1; i <= m; i++) {
    sc(b[i + 1]);
    b[i + 1]++;
  }
  b[1] = 1;
  m++;
  for (int i = 1; i <= n; i++) {
    if (binary_search(b + 1, b + m + 1, a[i])) {
      in[i] = lower_bound(b + 1, b + m + 1, a[i]) - b;
    }
  }
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[i] = 1e18;
  }
  long long ans = 0;
  Segtree_Without_Lazy<long long> s(n);
  long long tot = 0;
  for (int i = 2; i <= n; i++) {
    if (in[i]) {
      long long val = dp[b[in[i] - 1]] + s.query(b[in[i] - 1] + 1, n) + tot;
      if (p[i] < 0) tot += p[i];
      42;
      dp[a[i]] = min(dp[a[i]], val - s.query(a[i] + 1, n) - tot);
      if (p[i] >= 0) s.upd(a[i], p[i]);
    } else {
      if (p[i] < 0) {
        ans += p[i];
        continue;
      } else {
        s.upd(a[i], p[i]);
      }
    }
  }
  ans += dp[b[m]] + s.query(b[m] + 1, n) + tot;
  if (ans > 1e16) {
    cout << "NO" << '\n';
  } else {
    cout << "YES" << '\n';
    pr(ans);
  }
}
signed main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int tt = 1; tt <= t; tt++) {
    solve();
  }
  return 0;
}