#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int MX = 500005;
int n, a[MX], p[MX], m, b[MX], f[MX];
long long ft[MX], x[MX], sum, mn[MX];
void update(int i, long long k) {
  while (i < MX) {
    ft[i] += k;
    i += i & -i;
  }
}
long long query(int i) {
  long long s = 0;
  while (i) {
    s += ft[i];
    i -= i & -i;
  }
  return s;
}
long long query(int a, int b) { return query(b) - query(a - 1); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i + 1];
  for (int i = 0; i < n; i++) {
    cin >> p[i + 1];
    if (p[i + 1] < 0) sum += p[i + 1];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b[i + 1];
    f[b[i + 1]] = i + 1;
  }
  int j = 1;
  for (int i = 0; i < n; i++)
    if (j <= m && a[i + 1] == b[j]) j++;
  if (j <= m) {
    cout << "NO" << '\n';
    return 0;
  }
  for (int i = n; i; i--) {
    if (p[i] < 0)
      x[i] -= p[i];
    else
      update(a[i], p[i]);
    if (f[a[i]]) x[i] -= query(b[f[a[i]] - 1] + 1, a[i]);
  }
  fill(mn, mn + MX, inf);
  mn[m + 1] = 0;
  for (int i = n; i; i--)
    if (f[a[i]]) mn[f[a[i]]] = min(mn[f[a[i]]], x[i] + mn[f[a[i]] + 1]);
  cout << "YES" << '\n' << mn[1] + sum + query(n) << '\n';
  return 0;
}
