#include <bits/stdc++.h>
using namespace std;
int n, m;
int pos[600005], p[600005];
int a[600005], b[600005];
long long S[600005 << 2], lazy[600005 << 2];
void shift(int node, long long val) {
  S[node] += val;
  lazy[node] += val;
}
void push(int node) {
  shift(node << 1, lazy[node]);
  shift(node << 1 | 1, lazy[node]);
  lazy[node] = 0;
}
void up2(int node, int bas, int son, int l, int r, int val) {
  if (bas > r || son < l) return;
  if (bas >= l && son <= r) {
    lazy[node] += val;
    S[node] += val;
    return;
  }
  push(node);
  up2(node << 1, bas, ((bas + son) >> 1), l, r, val),
      up2(node << 1 | 1, ((bas + son) >> 1) + 1, son, l, r, val);
  S[node] = min(S[node << 1], S[node << 1 | 1]);
}
void up1(int node, int bas, int son, int x, long long val) {
  if (bas > x || son < x) return;
  if (bas == x && son == x) {
    S[node] = min(S[node], val);
    return;
  }
  push(node);
  up1(node << 1, bas, ((bas + son) >> 1), x, val),
      up1(node << 1 | 1, ((bas + son) >> 1) + 1, son, x, val);
  S[node] = min(S[node << 1], S[node << 1 | 1]);
}
long long get(int node, int bas, int son, int x) {
  if (bas > x || son < x) return (2ll * 1000000000 * 1000000000);
  if (bas == x && son == x) {
    return S[node];
  }
  push(node);
  return min(get(node << 1, bas, ((bas + son) >> 1), x),
             get(node << 1 | 1, ((bas + son) >> 1) + 1, son, x));
}
void build(int node, int bas, int son) {
  if (bas == son) {
    S[node] = (bas ? (2ll * 1000000000 * 1000000000) : 0);
    return;
  }
  build(node << 1, bas, ((bas + son) >> 1));
  build(node << 1 | 1, ((bas + son) >> 1) + 1, son);
  S[node] = (2ll * 1000000000 * 1000000000);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> p[i];
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> b[i], pos[b[i]] = i;
  build(1, 0, n);
  long long ans = (2ll * 1000000000 * 1000000000);
  for (int i = 1; i <= n; i++) {
    if (pos[a[i]]) {
      if (p[i] < 0) {
        up2(1, 0, n, a[i], n, p[i]);
      }
      int sm = b[pos[a[i]] - 1];
      long long best = get(1, 0, n, sm);
      up1(1, 0, n, a[i], best);
      up2(1, 0, n, 0, a[i] - 1, p[i]);
    } else {
      up2(1, 0, n, 0, a[i] - 1, p[i]);
      if (p[i] < 0) {
        up2(1, 0, n, a[i], n, p[i]);
      }
    }
  }
  ans = get(1, 0, n, b[m]);
  if (ans >= (2ll * 1000000000 * 1000000000) / 2)
    cout << "NO";
  else {
    cout << "YES\n";
    cout << ans;
  }
}
