#include <bits/stdc++.h>
using namespace std;
const long long BIG = 1LL << 55;
const long long INFTY = 1LL << 58;
const int MAXN = 500005;
int N, M;
int A[MAXN];
long long P[MAXN];
int B[MAXN];
int idx[MAXN];
long long BIT[MAXN];
long long sum = 0;
void add(int idx, long long val) {
  for (; idx < MAXN; idx += idx & -idx) BIT[idx] = min(INFTY, BIT[idx] + val);
}
long long get(int idx) {
  if (idx == 0) return sum;
  long long ret = 0;
  for (; idx > 0; idx -= idx & -idx) ret += BIT[idx];
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N; i++) cin >> P[i];
  cin >> M;
  for (int i = 1; i <= M; i++) cin >> B[i];
  for (int i = 1, j = 1; i <= N; i++) {
    while (j <= M && B[j] < i) j++;
    idx[i] = j;
  }
  add(1, INFTY);
  for (int i = 1; i <= N; i++) {
    long long same_val = INFTY;
    if (idx[A[i]] <= M && B[idx[A[i]]] == A[i]) same_val = get(idx[A[i]] - 1);
    add(1, P[i]);
    if (P[i] > 0) add(idx[A[i]], -P[i]);
    if (same_val != INFTY) {
      long long cur = get(idx[A[i]]);
      if (cur > same_val) {
        add(idx[A[i]], same_val - cur);
        add(idx[A[i]] + 1, cur - same_val);
      }
    }
    sum += P[i];
  }
  long long ans = get(M);
  if (ans >= BIG)
    cout << "NO\n";
  else
    cout << "YES\n" << ans << "\n";
  return 0;
}
