#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, m, a[N], p[N], b[N];
int id[N];
map<int, int> mp;
vector<int> lv[N];
long long f[N], t[N];
bool cmp(int x, int y) { return a[x] < a[y]; }
void change(int k, int v) {
  for (; k <= n; k += k & (-k)) t[k] += v;
}
long long ask(int k) {
  long long s = 0;
  for (; k; k -= k & (-k)) s += t[k];
  return s;
}
void solve() {
  memset(f, 233, sizeof(f));
  for (auto i : lv[1]) f[i] = p[i];
  int t = 1;
  for (int i = (int)(1); i <= (int)(m); i++) {
    for (; t <= n && a[id[t]] <= b[i]; ++t)
      if (p[id[t]] > 0) change(id[t], p[id[t]]);
    int pos = 0, x;
    long long val = -(1ll << 60);
    for (auto j : lv[i + 1]) {
      for (; pos < lv[i].size() && (x = lv[i][pos]) < j; ++pos)
        val = max(val, f[x] - ask(x));
      f[j] = val + ask(j) + p[j];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &a[i]);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &p[i]);
  scanf("%d", &m);
  for (int i = (int)(1); i <= (int)(m); i++) scanf("%d", &b[i]);
  a[++n] = b[++m] = 1 << 30;
  for (int i = (int)(1); i <= (int)(m); i++) mp[b[i]] = i;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (mp[a[i]]) lv[mp[a[i]]].push_back(i);
  for (int i = (int)(1); i <= (int)(n); i++) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  solve();
  if (f[n] < -1e15)
    puts("NO");
  else {
    puts("YES");
    long long ans = -f[n];
    for (int i = (int)(1); i <= (int)(n); i++) ans += p[i];
    printf("%lld\n", ans);
  }
}
