#include <bits/stdc++.h>
const int N = 5e5 + 5;
int n, m, a[N], b[N], id[N], q[N];
long long f[N], g[N], h[N], p[N];
int main() {
  scanf("%d", &n);
  int i, j;
  long long F, x = 0;
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  for (i = 1; i <= n; i++) scanf("%lld", p + i);
  scanf("%d", &m), n++, a[n] = n;
  for (i = 1; i <= m; i++) scanf("%d", b + i), id[b[i]] = i;
  m++, b[m] = n, id[n] = m, memset(g, 63, 8 * m + 8), F = g[0], g[0] = 0;
  for (i = j = 1; i <= n; q[i++] = j)
    if (b[j] < i) j++;
  for (i = 1; i <= n; i++) {
    j = id[a[i]];
    if (j) f[i] = g[j - 1] < F ? g[j - 1] + h[j] + x : F;
    if (p[i] > -1)
      h[q[a[i]]] += p[i];
    else
      x += p[i];
    if (j) (f[i] < F) && (g[j] = std::min(g[j], f[i] - x));
  }
  if (f[n] < F)
    printf("YES\n%lld", f[n]);
  else
    puts("NO");
  return 0;
}
