#include <bits/stdc++.h>
using namespace std;
long long segsize;
long long segt[2 * 500100];
void build() {
  for (long long i = segsize - 1; i > 0; --i)
    segt[i] = segt[i << 1] + segt[i << 1 | 1];
}
void modify(long long p, long long value) {
  for (segt[p += segsize] = value; p > 1; p >>= 1)
    segt[p >> 1] = segt[p] + segt[p ^ 1];
}
long long query(long long l, long long r) {
  long long res = 0;
  for (l += segsize, r += segsize; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += segt[l++];
    if (r & 1) res += segt[--r];
  }
  return res;
}
int main() {
  long long n;
  long long answ = 0;
  cin >> n;
  long long a[n + 1];
  long long p[n + 1];
  long long cost[n + 1];
  memset((p), 0, sizeof((p)));
  memset((a), 0, sizeof((a)));
  memset((cost), 0, sizeof((cost)));
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < (long long)(n); i++) {
    long long x;
    cin >> x;
    if (x > 0) {
      p[i] = x;
    } else {
      answ += x;
      cost[i] = -x;
    }
  }
  n += 1;
  a[n - 1] = n + 2;
  p[n - 1] = cost[n - 1] = 0;
  long long m;
  cin >> m;
  m += 1;
  long long b[m];
  set<long long> setb;
  unordered_map<long long, vector<long long> > row;
  for (long long i = 0; i < (long long)(m - 1); i++) {
    row[i].clear();
    cin >> b[i];
    setb.insert(b[i]);
  }
  row[m - 1].clear();
  b[m - 1] = n + 2;
  setb.insert(b[m - 1]);
  long long below[n];
  long long above[n + 1];
  memset((above), -1, sizeof((above)));
  for (long long i = 0; i < (long long)(n); i++) {
    set<long long>::iterator it = setb.find(a[i]);
    if (it != setb.end()) {
      row[a[i]].push_back(i);
      if (it == setb.begin()) {
        below[i] = 0;
      } else {
        it--;
        below[i] = *it;
      }
    }
  }
  segsize = n + 5;
  for (long long i = 0; i < (long long)(segsize); i++) {
    segt[segsize + i] = 0;
  }
  build();
  for (long long i = 0; i < (long long)(n); i++) {
    set<long long>::iterator it = setb.find(a[i]);
    if (it != setb.end()) {
      above[i] = query(below[i] + 1, a[i] + 1);
    }
    modify(a[i], segt[segsize + a[i]] + p[i]);
  }
  int fail = 0;
  for (long long i = 0; i < (long long)(m); i++) {
    if (row[b[i]].size() == 0) {
      fail++;
    }
  }
  if (fail != 0) {
    cout << "NO\n";
  } else {
    long long dp[n];
    long long i = 0;
    while (i <= m - 1) {
      if (i == 0) {
        for (auto dex : row[b[i]]) {
          dp[dex] = above[dex] + cost[dex];
        }
      } else {
        long long bdex = -1;
        long long minm = 1e17;
        for (auto dex : row[b[i]]) {
          while (row[b[i - 1]][bdex + 1] < dex &&
                 bdex != row[b[i - 1]].size() - 1) {
            bdex++;
            minm = min(minm, dp[row[b[i - 1]][bdex]]);
          }
          if (bdex == -1) {
            dp[dex] = 1e17;
          } else {
            dp[dex] = minm + cost[dex] + above[dex];
          }
        }
      }
      i++;
    }
    if (dp[n - 1] > 1e16) {
      cout << "NO\n";
    } else {
      long long k = dp[n - 1] + answ;
      cout << "YES\n" << k << '\n';
    }
  }
}
