#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int a[maxn], n, m, p[maxn], id[maxn], b[maxn];
long long BIT[maxn], res[maxn], s[maxn], sav[maxn];
void readf() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    if (p[i] < 0)
      s[i] = s[i - 1] + p[i];
    else
      s[i] = s[i - 1];
  }
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
    id[b[i]] = i;
  }
}
void update(int x, int val) {
  for (; x > 0; x -= -x & x) BIT[x] += val;
}
long long get(int x) {
  long long ans = 0;
  for (; x <= n; x += -x & x) ans += BIT[x];
  return ans;
}
void solve() {
  long long neg = 0;
  for (int i = n; i > 0; --i) {
    sav[i] = get(a[i] + 1) + neg;
    if (p[i] <= 0)
      neg += p[i];
    else
      update(a[i], p[i]);
  }
  memset(BIT, 0, sizeof(BIT));
  memset(res, 0x3f, sizeof(res));
  res[0] = 0;
  for (int i = 1; i <= n; ++i) {
    if (id[a[i]] == m) {
      res[a[i]] = min(res[a[i]], s[i - 1] + res[b[id[a[i]] - 1]] +
                                     get(b[id[a[i]] - 1] + 1) + sav[i]);
    } else if (id[a[i]] > 0) {
      res[a[i]] =
          min(res[a[i]], s[i - 1] + res[b[id[a[i]] - 1]] +
                             get(b[id[a[i]] - 1] + 1) - get(a[i] + 1) - s[i]);
    }
    if (p[i] > 0) update(a[i], p[i]);
  }
  if (res[b[m]] > 1e18) {
    cout << "NO\n";
    exit(0);
  }
  cout << "YES\n";
  cout << res[b[m]] << '\n';
}
int main() {
  srand(time(NULL));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  readf();
  solve();
}
