#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const long long oo = 1e16 + 5;
int du[] = {-1, 0, 0, 1};
int dv[] = {0, -1, 1, 0};
const long long mod = 1e9 + 7;
long long sqr(long long x) { return x * x; }
int getbit(int state, int i) { return ((state >> i) & 1); }
int n, m, a[N + 5], b[N + 5];
long long f[N + 5], dp[N + 5], c[N + 5], neg[N + 5], t[N + 5];
vector<int> List[N + 5];
void update(int u, long long val) {
  for (int i = u; i <= N; i += i & -i) f[i] += val;
}
long long get(int u) {
  long long tmp = 0;
  for (int i = u; i > 0; i -= i & -i) tmp += f[i];
  return tmp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  n++;
  a[n] = n;
  c[n] = 0;
  for (int i = 1; i <= n; i++) {
    List[a[i]].push_back(i);
    neg[i] = neg[i - 1];
    if (c[i] < 0)
      neg[i] += c[i];
    else
      update(i, c[i]);
    t[i] = t[i - 1] + c[i];
  }
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> b[i];
  for (int i = 0; i < List[b[1]].size(); i++)
    dp[List[b[1]][i]] = t[List[b[1]][i] - 1];
  m++;
  b[m] = n;
  for (int k = 2; k <= m; k++) {
    int v = b[k - 1], u = b[k], vt = 0;
    for (int i = b[k - 2] + 1; i <= v; i++)
      for (int j = 0; j < List[i].size(); j++)
        if (c[List[i][j]] > 0) update(List[i][j], -c[List[i][j]]);
    if (List[u].empty()) {
      cout << "NO";
      return 0;
    }
    if (List[v].empty()) {
      cout << "NO";
      return 0;
    }
    long long Min = oo;
    for (int i = 0, j = 0; i < List[u].size(); i++) {
      while (j < List[v].size() && List[v][j] < List[u][i]) {
        if (j > 0 && Min < oo)
          Min += (neg[List[v][j]] - neg[List[v][j - 1]]) + get(List[v][j]) -
                 get(List[v][j - 1]);
        Min = min(Min, dp[List[v][j]]);
        vt = List[v][j];
        j++;
      }
      if (Min < oo)
        dp[List[u][i]] =
            Min + neg[List[u][i] - 1] - neg[vt] + get(List[u][i] - 1) - get(vt);
      else
        dp[List[u][i]] = oo;
    }
  }
  if (dp[n] >= oo)
    cout << "NO" << endl;
  else
    cout << "YES" << endl << dp[n];
  return 0;
}
