#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e17;
namespace ProconLib {
template <typename Int>
struct BIT {
 private:
  int N;
  std::vector<Int> dat;

 public:
  BIT(int N) : N(N), dat(N, 0) {}
  void add(int pos, Int x);
  Int sum(int r);
  Int sum(int l, int r);
};
template <typename Int>
void BIT<Int>::add(int pos, Int x) {
  pos++;
  while (pos <= N) {
    dat[pos - 1] += x;
    pos += pos & -pos;
  }
}
template <typename Int>
Int BIT<Int>::sum(int r) {
  Int res = 0;
  while (r > 0) {
    res += dat[r - 1];
    r -= r & -r;
  }
  return res;
}
template <typename Int>
Int BIT<Int>::sum(int l, int r) {
  return sum(r) - sum(l);
}
};  // namespace ProconLib
using namespace ProconLib;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
  vector<ll> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int m;
  cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; i++) cin >> b[i], b[i]--;
  vector<int> mp(n, -1);
  for (int i = 0; i < m; i++) mp[b[i]] = i;
  BIT<ll> dp(m + 2);
  dp.add(1, INF);
  for (int i = 0; i < n; i++) {
    bool flag = mp[a[i]] != -1;
    int pos;
    ll tmp;
    if (mp[a[i]] != -1) {
      pos = mp[a[i]];
      tmp = dp.sum(0, pos + 1);
    }
    int r = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    if (p[i] >= 0) {
      dp.add(0, p[i]);
      dp.add(r + 1, -p[i]);
    } else {
      dp.add(0, p[i]);
    }
    if (flag) {
      ll pre = dp.sum(0, pos + 2);
      if (tmp < pre) {
        ll diff = tmp - pre;
        dp.add(pos + 1, diff);
        dp.add(pos + 2, -diff);
      }
    }
  }
  if (dp.sum(0, m + 1) >= INF / 10) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    cout << dp.sum(0, m + 1) << endl;
  }
  return 0;
}
