#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  long long ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
inline long long min(long long x, long long y, long long z) {
  return min(x, min(y, z));
}
inline long long max(long long x, long long y, long long z) {
  return max(x, max(y, z));
}
inline long long add(long long x, long long y) {
  return x + y >= 998244353 ? x + y - 998244353 : x + y;
}
inline long long add(long long x, long long y, long long z) {
  return add(add(x, y), z);
}
inline long long sub(long long x, long long y) {
  return x - y < 0 ? x - y + 998244353 : x - y;
}
inline long long mul(long long x, long long y) {
  return 1LL * x * y % 998244353;
}
inline long long mul(long long x, long long y, long long z) {
  return mul(mul(x, y), z);
}
long long a[500005], b[500005], c[500005], p[500005], sum[500005];
long long f[500005], v[500005], n, m;
long long t[500005];
long long lowbit(long long u) { return u & (-u); }
void update(long long u, long long d) {
  while (u <= n) {
    t[u] += d;
    u += lowbit(u);
  }
}
long long query(long long u) {
  long long ans = 0;
  while (u) {
    ans += t[u];
    u -= lowbit(u);
  }
  return ans;
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) p[i] = read();
  for (long long i = 1; i <= n; i++) sum[i] = sum[i - 1] + p[i];
  cin >> m;
  for (long long i = 1; i <= m; i++) b[i] = read();
  for (long long i = 1; i <= m; i++) c[b[i]] = i;
  long long cur = 1;
  for (long long i = 1; i <= n; i++) {
    if (cur <= m && a[i] == b[cur]) cur++;
  }
  if (cur <= m) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (long long i = 1; i <= m; i++) f[i] = 0x3f3f3f3f3f3f3f3f;
  for (long long i = 1; i <= n; i++) {
    if (c[a[i]]) {
      long long qaq = c[a[i]];
      v[i] = f[qaq - 1] + sum[i - 1] - query(b[qaq - 1]);
      if (p[i] > 0) update(a[i], p[i]);
      long long R = v[i] - sum[i] + query(b[qaq]);
      if (R < f[qaq]) f[qaq] = R;
    } else if (p[i] > 0)
      update(a[i], p[i]);
  }
  long long res = 0, ans = 0x3f3f3f3f3f3f3f3f;
  for (long long i = n; i >= 1; i--) {
    if (a[i] == b[m]) {
      if (v[i] + res < ans) ans = v[i] + res;
      if (p[i] < 0) res += p[i];
    } else if (a[i] > b[m] || p[i] < 0)
      res += p[i];
  }
  cout << ans << endl;
  return 0;
}
