#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long lowbit(long long x) { return x & -x; }
const long long N = 500001, M = N;
long long n, m;
long long a[N + 1], p[N + 1], b[M + 1];
long long id[N + 1];
struct bitree {
  long long sum[N + 1];
  void init() { memset(sum, 0, sizeof(sum)); }
  void add(long long x, long long v) {
    while (x <= n) sum[x] += v, x += lowbit(x);
  }
  long long Sum(long long x) {
    long long res = 0;
    while (x) res += sum[x], x -= lowbit(x);
    return res;
  }
  long long _sum(long long l, long long r) { return Sum(r) - Sum(l - 1); }
} bit;
long long now[M + 1];
long long dp[N + 1];
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) scanf("%lld", a + i);
  n++;
  a[n] = n;
  for (long long i = 1; i < n; i++) scanf("%lld", p + i);
  cin >> m;
  for (long long i = 1; i <= m; i++) scanf("%lld", b + i), id[b[i]] = i;
  b[++m] = n;
  id[n] = m;
  bit.init();
  memset(now, 0x3f, sizeof(now));
  now[0] = 0;
  long long ne = 0;
  for (long long i = 1; i <= n; i++) {
    if (id[a[i]]) {
      if (now[id[a[i]] - 1] < inf)
        dp[i] = now[id[a[i]] - 1] + bit._sum(b[id[a[i]] - 1] + 1, n) + ne;
      else
        dp[i] = inf;
      if (p[i] >= 0)
        bit.add(a[i], p[i]);
      else
        ne += p[i];
      if (dp[i] < inf)
        now[id[a[i]]] = min(now[id[a[i]]], dp[i] - bit._sum(a[i] + 1, n) - ne);
    } else {
      if (p[i] >= 0)
        bit.add(a[i], p[i]);
      else
        ne += p[i];
    }
  }
  if (dp[n] < inf)
    cout << "YES\n" << dp[n];
  else
    puts("NO");
  return 0;
}
