#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
using namespace std;
const int N = 5e5 + 8;
long long n, m, a[N], b[N], p[N], c[N], dp[N];
vector<int> g[N];
void add(int x, long long y) {
  while (x <= n) c[x] += y, x += x & -x;
}
long long sum(int x) {
  long long res = 0;
  while (x > 0) res += c[x], x -= x & -x;
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i(1); i <= (n); ++i) scanf("%lld", &a[i]), g[a[i]].push_back(i);
  for (int i(1); i <= (n); ++i) scanf("%lld", &p[i]), add(i, p[i]);
  cin >> m;
  for (int i(1); i <= (m); ++i) scanf("%lld", &b[i]);
  b[m + 1] = n + 1;
  g[0].push_back(0);
  g[n + 1].push_back(n + 1);
  memset(dp, inff, sizeof(dp)), dp[0] = 0;
  for (int ii(1); ii <= (m + 1); ++ii) {
    int zz = 0, sz = g[b[ii - 1]].size(), i = b[ii];
    for (int j = 0; j < g[i].size(); j++) {
      if (j)
        dp[g[i][j]] = min(dp[g[i][j]], dp[g[i][j - 1]] + sum(g[i][j] - 1) -
                                           sum(g[i][j - 1]) + p[g[i][j - 1]]);
      while (zz < sz && g[b[ii - 1]][zz] < g[i][j]) {
        dp[g[i][j]] = min(dp[g[i][j]], dp[g[b[ii - 1]][zz]] + sum(g[i][j] - 1) -
                                           sum(g[b[ii - 1]][zz]));
        zz++;
      }
    }
    for (int j(b[ii - 1] + 1); j <= (b[ii]); ++j)
      for (int zs = 0; zs < g[j].size(); zs++)
        if (p[g[j][zs]] > 0) add(g[j][zs], -p[g[j][zs]]);
  }
  if (dp[n + 1] > 1e17)
    puts("NO");
  else
    printf("YES\n%lld\n", dp[n + 1]);
  return 0;
}
