#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a, b, cost;
map<int, vector<int> > pos_at_value;
bool valid() {
  int cur = 0;
  for (int x : a) {
    if (b[cur] == x) cur++;
    if (cur >= m) {
      return 1;
    }
  }
  return 0;
}
struct BinaryIndexedTree {
  long long T[500005] = {0};
  void add(int x, long long v) {
    for (++x; x < 500005; x += x & -x) T[x] += v;
  }
  long long sum(int x) {
    long long ret = 0;
    for (++x; x; x -= x & -x) ret += T[x];
    return ret;
  }
};
long long T[500005 << 2];
int leaf[500005 + 5];
void build(int id = 1, int l = 0, int r = 500005) {
  T[id] = 0x3f3f3f3f3f3f3f3f;
  if (l + 1 == r) {
    leaf[l] = id;
    return;
  }
  build(id << 1, l, l + r >> 1);
  build(id << 1 | 1, l + r >> 1, r);
}
void update(int x, long long val) {
  T[leaf[x]] = val;
  for (int cur = leaf[x] / 2; cur; cur /= 2) {
    T[cur] = min(T[cur * 2], T[cur * 2 + 1]);
  }
}
long long ask(int x, int y, int id = 1, int l = 0, int r = 500005) {
  if (y <= l || r <= x) return 0x3f3f3f3f3f3f3f3f;
  if (x <= l && r <= y) return T[id];
  return min(ask(x, y, id << 1, l, l + r >> 1),
             ask(x, y, id << 1 | 1, l + r >> 1, r));
}
void solve() {
  cin >> n;
  a.resize(n), cost.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pos_at_value[a[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> cost[i];
  cin >> m;
  b.resize(n);
  for (int i = 0; i < m; i++) cin >> b[i];
  if (not valid()) {
    cout << "NO\n";
    return;
  } else {
    cout << "YES\n";
  }
  BinaryIndexedTree ps;
  build();
  deque<pair<int, int> > q;
  for (int i = 0; i < n; i++) {
    ps.add(i, cost[i]);
    q.push_back(make_pair(a[i], i));
  }
  sort(q.begin(), q.end());
  vector<pair<int, long long> > prev_candidates;
  for (int iter = 0; iter < m; iter++) {
    int target = b[iter];
    if (0) cerr << "cur " << target << '\n';
    for (auto op : prev_candidates) {
      if (0)
        cerr << "  update " << op.first << ' ' << op.second << '-'
             << ps.sum(op.first) << ' ' << op.second - ps.sum(op.first) << '\n';
      update(op.first, op.second - ps.sum(op.first));
    }
    vector<pair<int, long long> > cur_candidates;
    for (int pos : pos_at_value[target]) {
      cur_candidates.push_back({pos, ps.sum(pos - 1) + !!iter * ask(0, pos)});
      if (0) cerr << "  ps " << ps.sum(pos - 1) << '\n';
      if (0)
        cerr << "  candidate " << pos << ' '
             << ps.sum(pos - 1) + !!iter * ask(0, pos) << '\n';
    }
    for (auto op : prev_candidates) {
      update(op.first, 0x3f3f3f3f3f3f3f3f);
    }
    swap(cur_candidates, prev_candidates);
    while (q.size() && q.front().first <= target) {
      int pos = q.front().second;
      if (cost[pos] > 0) {
        ps.add(pos, -cost[pos]);
        if (0)
          cerr << "  remove " << pos << ' ' << a[pos] << ' ' << -cost[pos]
               << '\n';
      }
      q.pop_front();
    }
  }
  long long ans = 0x3f3f3f3f3f3f3f3f;
  for (auto op : prev_candidates)
    ans = min(ans, op.second + ps.sum(n - 1) - ps.sum(op.first));
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int no = 1; no <= t; no++) {
    solve();
  }
}
