#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void prn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prn(args...);
}
template <typename Arg1>
void prs(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prs(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
const long long inf = 1e18, lim = 1e15;
int n;
vector<int> arr, p, pos, b;
vector<long long> tree, lazy;
inline void build(int st, int en, int node) {
  if (st == en) {
    tree[node] = inf;
    return;
  }
  int mid = (st + en) >> 1;
  build(st, mid, (node << 1));
  build(mid + 1, en, (node << 1) | 1);
}
inline void push(int st, int en, int node) {
  if (st == en)
    tree[node] += lazy[node];
  else {
    lazy[node << 1] += lazy[node];
    lazy[(node << 1) | 1] += lazy[node];
  }
  lazy[node] = 0;
}
inline void update(int st, int en, int node, int l, int r, long long nv) {
  if (lazy[node]) push(st, en, node);
  if (st > r || en < l) return;
  if (st >= l && en <= r) {
    lazy[node] = nv;
    push(st, en, node);
    return;
  }
  int mid = (st + en) >> 1;
  update(st, mid, node << 1, l, r, nv);
  update(mid + 1, en, (node << 1) | 1, l, r, nv);
}
inline void pupdate(int st, int en, int node, int idx, long long nv) {
  if (lazy[node]) push(st, en, node);
  if (st > idx || en < idx) return;
  if (st == en) {
    tree[node] = nv;
    return;
  }
  int mid = (st + en) >> 1;
  pupdate(st, mid, node << 1, idx, nv);
  pupdate(mid + 1, en, (node << 1) | 1, idx, nv);
}
inline long long query(int st, int en, int node, int idx) {
  if (lazy[node]) push(st, en, node);
  if (st == en) return tree[node];
  int mid = (st + en) >> 1;
  if (idx <= mid) return query(st, mid, node << 1, idx);
  return query(mid + 1, en, (node << 1) | 1, idx);
}
void solve() {
  read(n);
  arr.resize(n);
  for (int i = 0; i < n; ++i) {
    read(arr[i]);
  }
  p.resize(n);
  for (int i = 0; i < n; ++i) {
    read(p[i]);
  }
  int m;
  read(m);
  pos.resize(n + 1, -1);
  pos[0] = 0;
  b.resize(m + 1);
  b[0] = 0;
  for (int i = 1; i <= m; ++i) {
    int x;
    read(x);
    b[i] = x;
    pos[x] = i;
  }
  tree.resize(4 * m + 4);
  lazy.resize(4 * m + 4, 0);
  build(0, m, 1);
  pupdate(0, m, 1, 0, 0);
  int lst = 0;
  for (int i = 0; i < n; ++i) {
    int cur = arr[i], cost = p[i];
    if (pos[cur] != -1) {
      if (lst >= pos[cur] - 1) {
        lst = max(lst, pos[cur]);
        long long bst = query(0, m, 1, pos[cur] - 1),
                  prev = query(0, m, 1, pos[cur]);
        if (cost >= 0) {
          if (bst < prev) pupdate(0, m, 1, pos[cur], bst);
        } else {
          if (bst < prev + cost)
            pupdate(0, m, 1, pos[cur], bst);
          else
            update(0, m, 1, pos[cur], pos[cur], cost);
        }
      }
    }
    int idx = lower_bound(b.begin(), b.end(), cur) - b.begin();
    idx = min(idx - 1, lst);
    update(0, m, 1, 0, idx, cost);
    if (cost >= 0 || cur > b.back()) continue;
    idx = upper_bound(b.begin(), b.end(), cur) - b.begin();
    if (idx <= lst) update(0, m, 1, idx, lst, cost);
  }
  if (lst == m) {
    prn("YES");
    prn(query(0, m, 1, m));
  } else
    prn("NO");
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    solve();
  }
  return 0;
}
