#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 5, inf = 1e16;
long long a[N], p[N], b[N], seg[N << 2], m;
void shift(long long id) {
  if (seg[id] == 0) return;
  seg[id << 1] += seg[id], seg[id << 1 | 1] += seg[id];
  seg[id] = 0;
}
void add(long long l, long long r, long long val, long long L = 0,
         long long R = m + 1, long long id = 1) {
  if (r <= L || R <= l) return;
  if (l <= L && R <= r) {
    seg[id] += val;
    return;
  }
  shift(id);
  long long mid = (L + R) >> 1;
  add(l, r, val, L, mid, id << 1);
  add(l, r, val, mid, R, id << 1 | 1);
  return;
}
long long get(long long l, long long L = 0, long long R = m + 1,
              long long id = 1) {
  if (R - L == 1) return seg[id];
  shift(id);
  long long mid = (L + R) >> 1;
  if (l < mid)
    return get(l, L, mid, id << 1);
  else
    return get(l, mid, R, id << 1 | 1);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> p[i];
  cin >> m;
  for (long long i = 1; i <= m; i++) cin >> b[i];
  add(1, m + 1, inf);
  for (long long i = 0; i < n; i++) {
    long long x = lower_bound(b, b + m + 1, a[i]) - b, val = inf * 10;
    if (a[i] == b[x]) val = get(x - 1);
    if (p[i] < 0)
      add(0, m + 1, p[i]);
    else
      add(0, x, p[i]);
    if (val < get(x)) add(x, x + 1, val - get(x));
  }
  if (get(m) > 1e15) return cout << "NO\n", 0;
  cout << "YES\n" << get(m) << "\n";
}
