#include <bits/stdc++.h>
using namespace std;
int n, m, a[500500], p[500500], b[500500];
long long f[500500];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  f[1] = 1e18;
  for (int i = 1; i <= n; i++) {
    int t = lower_bound(b + 1, b + m + 1, a[i]) - b;
    f[0] += p[i];
    f[p[i] < 0 ? m + 1 : t] -= p[i];
    if (b[t] == a[i] && f[t] + p[i] > 0) {
      f[t + 1] += f[t] + p[i];
      f[t] = -p[i];
    }
  }
  for (int i = 1; i <= m; i++) f[i] += f[i - 1];
  if (f[m] < 1e17)
    printf("YES\n%lld\n", f[m]);
  else
    puts("NO");
  return 0;
}
