#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, mod = 1e9 + 7;
long long seg[4 * N], flag[4 * N];
int a[N], p[N], b[N];
inline void relax(int ind) {
  long long x = flag[ind];
  flag[ind] = 0;
  seg[2 * ind] += x;
  seg[2 * ind + 1] += x;
  flag[2 * ind] += x;
  flag[2 * ind + 1] += x;
}
void add(int s, int e, int ind, int l, int r, long long val, int tp) {
  if (s >= r || e <= l) return;
  if (s >= l && e <= r) {
    if (tp == 0)
      seg[ind] = min(seg[ind], val);
    else
      seg[ind] += val, flag[ind] += val;
    return;
  }
  relax(ind);
  int mid = (s + e) / 2;
  add(s, mid, 2 * ind, l, r, val, tp);
  add(mid, e, 2 * ind + 1, l, r, val, tp);
}
long long get(int s, int e, int ind, int l, int r) {
  if (s >= r || e <= l) return 1ll * mod * mod;
  if (s >= l && e <= r) return seg[ind];
  relax(ind);
  int mid = (s + e) / 2;
  return min(get(s, mid, 2 * ind, l, r), get(mid, e, 2 * ind + 1, l, r));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> p[i];
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> b[i];
  for (int i = 0; i < 4 * N; i++) seg[i] = 1ll * mod * mod;
  add(0, m + 1, 1, 0, 1, 0, 0);
  for (int i = 0; i < n; i++) {
    int id = lower_bound(b + 1, b + m + 1, a[i]) - b;
    long long ret = get(0, m + 1, 1, id - 1, id);
    if (p[i] > 0)
      add(0, m + 1, 1, 0, id, p[i], 1);
    else
      add(0, m + 1, 1, 0, m + 1, p[i], 1);
    if (id <= m && b[id] == a[i]) add(0, m + 1, 1, id, id + 1, ret, 0);
  }
  long long ans = get(0, m + 1, 1, m, m + 1);
  if (ans >= 1ll * mod * mod / 10)
    cout << "NO";
  else
    cout << "YES\n" << ans;
  return 0;
}
