#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
const int N = 5e5 + 1;
int n, m;
int a[N + 1], p[N + 1], b[N + 1], pos[N + 1];
long long sum[N + 1];
struct Seg {
  long long tr[(N + 1) * 4 + 1], tag[(N + 1) * 4 + 1];
  inline void pushup(int now) {
    tr[now] = tr[(now << 1)] + tr[((now << 1) + 1)];
    return;
  }
  inline void build(int now, int l, int r) {
    if (l == r) {
      tr[now] = 1e15;
      return;
    }
    build((now << 1), l, ((l + r) >> 1));
    build(((now << 1) + 1), ((l + r) >> 1) + 1, r);
    pushup(now);
    return;
  }
  inline void pushdown(int now, int l, int r) {
    if (tag[now]) {
      tr[(now << 1)] += tag[now] * (((l + r) >> 1) - l + 1);
      tag[(now << 1)] += tag[now];
      tr[((now << 1) + 1)] += tag[now] * (r - ((l + r) >> 1));
      tag[((now << 1) + 1)] += tag[now];
      tag[now] = 0;
    }
    return;
  }
  inline void update(int now, int l, int r, int pos, long long val) {
    if (l == r) {
      tr[now] = min(tr[now], val);
      return;
    }
    pushdown(now, l, r);
    if (pos <= ((l + r) >> 1))
      update((now << 1), l, ((l + r) >> 1), pos, val);
    else
      update(((now << 1) + 1), ((l + r) >> 1) + 1, r, pos, val);
    pushup(now);
    return;
  }
  inline void add(int now, int l, int r, int L, int R, long long val) {
    if (l >= L && r <= R) {
      tr[now] += (r - l + 1) * val;
      tag[now] += val;
      return;
    }
    pushdown(now, l, r);
    if (((l + r) >> 1) >= L) add((now << 1), l, ((l + r) >> 1), L, R, val);
    if (((l + r) >> 1) < R)
      add(((now << 1) + 1), ((l + r) >> 1) + 1, r, L, R, val);
    pushup(now);
    return;
  }
  inline long long query(int now, int l, int r, int pos) {
    if (l == r) return tr[now];
    pushdown(now, l, r);
    long long sum;
    if (pos <= ((l + r) >> 1))
      sum = query((now << 1), l, ((l + r) >> 1), pos);
    else
      sum = query(((now << 1) + 1), ((l + r) >> 1) + 1, r, pos);
    pushup(now);
    return sum;
  }
};
Seg seg;
long long ans = 1e18;
inline void dp() {
  for (int i = 1; i <= n; i++) {
    long long w = 1e18;
    if (pos[a[i]] != -1) {
      if (pos[a[i]] == 1)
        w = sum[i - 1];
      else
        w = seg.query(1, 0, n, b[pos[a[i]] - 1]);
    }
    if (p[i] < 0)
      seg.add(1, 0, n, 0, n, p[i]);
    else
      seg.add(1, 0, n, 0, a[i] - 1, p[i]);
    seg.update(1, 0, n, a[i], w);
    if (pos[a[i]] == m) ans = min(ans, w);
  }
  return;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    pos[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    p[i] = read();
    sum[i] = sum[i - 1] + p[i];
  }
  a[n + 1] = N;
  sum[n + 1] = sum[n];
  n++;
  m = read();
  pos[0] = 0;
  for (int i = 1; i <= m; i++) {
    b[i] = read();
    pos[b[i]] = i;
  }
  b[m + 1] = N;
  pos[N] = m + 1;
  m++;
  seg.build(1, 0, n);
  dp();
  if (ans > 5e14)
    printf("NO\n");
  else
    printf("YES\n%lld\n", ans);
  return 0;
}
