#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long R = 7 + 1e9, NUMTESTCASE;
const long long NN = 10 + 1e6;
const double pi = acos(-1.0);
int di[8] = {1, 0, -1, 0, 1, -1, 1, -1}, dj[8] = {0, 1, 0, -1, 1, -1, -1, 1};
long long Bit[NN], Cost[NN], Memo[NN];
int n, m, Brr[NN], x, Cnt[NN], Next[NN], Adj[NN];
vector<int> Pos[NN];
long long Memo2[NN];
void Update(int Node, int Val) {
  while (Node <= n) {
    Bit[Node] += Val;
    Node += Node & (-Node);
  }
}
long long Sum(int Node) {
  long long Res = 0;
  while (Node) {
    Res += Bit[Node];
    Node -= Node & (-Node);
  }
  return Res;
}
void EndPrg() {
  for (int i = (1); i <= (n); ++i) {
    for (int u : Pos[i])
      if (Cost[u] < 0) Update(u, Cost[u]);
    if (!Cnt[i]) continue;
    for (int u : Pos[i]) Memo[u] = Sum(n) - Sum(u);
    for (int j = i; j >= 1; j--) {
      if (Cnt[j] && j != i) break;
      for (int u : Pos[j])
        if (Cost[u] < 0) Update(u, -Cost[u]);
    }
  }
  for (int i = (1); i <= (n); ++i)
    if (Cnt[i])
      for (int u : Pos[i]) Memo[u] += Cost[u], Memo2[u] = Memo[u];
  for (int Index = m, Limit = n; Index >= 1; Index--) {
    while (true) {
      if (!Pos[Brr[Index]].size() || Cnt[Brr[Index]] > 1) exit(puts("NO"));
      if (Pos[Brr[Index]].back() > Limit)
        Pos[Brr[Index]].pop_back();
      else
        break;
    }
    Limit = Pos[Brr[Index]].back();
  }
}
void BuildNext() {
  for (int Curr = n, Last = -1, k, u; Curr >= 1; Curr--) {
    if (!Cnt[Curr]) continue;
    if (Last == -1) {
      Last = Curr;
      continue;
    }
    k = Pos[Last].size() - 1;
    for (int i = Pos[Curr].size() - 1; i >= 0; i--) {
      u = Pos[Curr][i];
      k += 2;
      if (k >= Pos[Last].size()) k = Pos[Last].size() - 1;
      while (k >= 0 && Pos[Last][k] > u) Next[u] = Pos[Last][k--];
    }
    Last = Curr;
  }
  for (int u = (1); u <= (n); ++u)
    if (Cnt[u])
      for (int i = 1; i < Pos[u].size(); i++) Adj[Pos[u][i - 1]] = Pos[u][i];
}
bool Vis[NN], Final[NN];
long long Dp(int u) {
  if (u == Pos[Brr[m]].back()) return Memo[u];
  if (u <= 0) return 1e18;
  if (Vis[u]) return Memo2[u];
  Vis[u] = true;
  return Memo2[u] =
             min(Dp(Adj[u]), Memo[u] + (long long)(1 - Final[u]) * Dp(Next[u]));
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) scanf("%d", &x), Pos[x].push_back(i);
  for (int i = (1); i <= (n); ++i) scanf("%lld", Cost + i), Cost[i] *= -1;
  cin >> m;
  for (int i = (1); i <= (m); ++i) scanf("%d", Brr + i), Cnt[Brr[i]]++;
  EndPrg();
  BuildNext();
  for (int u : Pos[Brr[m]]) Final[u] = true;
  long long Ans = 0;
  for (int i = (1); i <= (n); ++i) Ans += -Cost[i];
  cout << "YES\n" << Ans + Dp(Pos[Brr[1]][0]);
  return 0;
}
