Problem: Let's denote the following function f. This function takes an array a of length n and returns an array. Initially the result is an empty array. For each integer i from 1 to n we add element a_i to the end of the resulting array if it is greater than all previous elements (more formally, if a_i > max_{1 ≤ j < i}a_j). Some examples of the function f:

  1. if a = [3, 1, 2, 7, 7, 3, 6, 7, 8] then f(a) = [3, 7, 8]; 
  2. if a = [1] then f(a) = [1]; 
  3. if a = [4, 1, 1, 2, 3] then f(a) = [4]; 
  4. if a = [1, 3, 1, 2, 6, 8, 7, 7, 4, 11, 10] then f(a) = [1, 3, 6, 8, 11]. 



You are given two arrays: array a_1, a_2, ... , a_n and array b_1, b_2, ... , b_m. You can delete some elements of array a (possibly zero). To delete the element a_i, you have to pay p_i coins (the value of p_i can be negative, then you get |p_i| coins, if you delete this element). Calculate the minimum number of coins (possibly negative) you have to spend for fulfilling equality f(a) = b.

Input

The first line contains one integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the length of array a.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — the array a.

The third line contains n integers p_1, p_2, ..., p_n (|p_i| ≤ 10^9) — the array p.

The fourth line contains one integer m (1 ≤ m ≤ n) — the length of array b.

The fifth line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ n, b_{i-1} < b_i) — the array b.

Output

If the answer exists, in the first line print YES. In the second line, print the minimum number of coins you have to spend for fulfilling equality f(a) = b.

Otherwise in only line print NO.

Examples

Input


11
4 1 3 3 7 8 7 9 10 7 11
3 5 0 -2 5 3 6 7 8 2 4
3
3 7 10


Output


YES
20


Input


6
2 1 5 3 6 5
3 -9 0 16 22 -14
4
2 3 5 6


Output


NO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2e9;
const long long INFLL = 1e15;
const int MAX_N = 500000;
int N, M;
int arr[MAX_N + 1];
long long cost[MAX_N + 1];
long long Mn[MAX_N + 1];
int b[MAX_N + 1];
int idx[MAX_N + 1];
struct SEG {
  struct NODE {
    int l, r;
    long long mn, lazy;
  };
  vector<NODE> seg;
  int SZ;
  void add() { seg.push_back({-1, -1, INFLL, 0LL}); }
  void Init(int x) {
    SZ = x;
    add();
    init(0, 1, SZ);
  }
  void init(int idx, int s, int e) {
    if (s == e) return;
    seg[idx].l = seg.size();
    add();
    seg[idx].r = seg.size();
    add();
    init(seg[idx].l, s, (s + e) / 2);
    init(seg[idx].r, (s + e) / 2 + 1, e);
  }
  void Add(int x, int y, long long z) { add2(0, 1, SZ, x, y, z); }
  void add2(int idx, int s, int e, int x, int y, long long z) {
    if (x <= s && e <= y) {
      if (seg[idx].mn == INFLL) return;
      seg[idx].lazy += z;
      seg[idx].mn += z;
      return;
    }
    if (x > e || y < s) return;
    if (seg[idx].lazy != 0) {
      if (seg[seg[idx].l].mn != INFLL) {
        seg[seg[idx].l].mn += seg[idx].lazy;
        seg[seg[idx].l].lazy += seg[idx].lazy;
      }
      if (seg[seg[idx].r].mn != INFLL) {
        seg[seg[idx].r].mn += seg[idx].lazy;
        seg[seg[idx].r].lazy += seg[idx].lazy;
      }
      seg[idx].lazy = 0;
    }
    add2(seg[idx].l, s, (s + e) / 2, x, y, z);
    add2(seg[idx].r, (s + e) / 2 + 1, e, x, y, z);
    seg[idx].mn = min(seg[seg[idx].l].mn, seg[seg[idx].r].mn);
  }
  long long Mn(int x) { return mn(0, 1, SZ, x); }
  long long mn(int idx, int s, int e, int k) {
    if (s == e) return seg[idx].mn;
    if (seg[idx].lazy != 0) {
      if (seg[seg[idx].l].mn != INFLL) {
        seg[seg[idx].l].mn += seg[idx].lazy;
        seg[seg[idx].l].lazy += seg[idx].lazy;
      }
      if (seg[seg[idx].r].mn != INFLL) {
        seg[seg[idx].r].mn += seg[idx].lazy;
        seg[seg[idx].r].lazy += seg[idx].lazy;
      }
      seg[idx].lazy = 0;
    }
    if (k <= (s + e) / 2) {
      return mn(seg[idx].l, s, (s + e) / 2, k);
    } else {
      return mn(seg[idx].r, (s + e) / 2 + 1, e, k);
    }
  }
  void Update(int x, long long y) { update(0, 1, SZ, x, y); }
  void update(int idx, int s, int e, int x, long long y) {
    if (s == e) {
      seg[idx].mn = min(seg[idx].mn, y);
      return;
    }
    if (seg[idx].lazy != 0) {
      if (seg[seg[idx].l].mn != INFLL) {
        seg[seg[idx].l].mn += seg[idx].lazy;
        seg[seg[idx].l].lazy += seg[idx].lazy;
      }
      if (seg[seg[idx].r].mn != INFLL) {
        seg[seg[idx].r].mn += seg[idx].lazy;
        seg[seg[idx].r].lazy += seg[idx].lazy;
      }
      seg[idx].lazy = 0;
    }
    if (x <= (s + e) / 2) {
      update(seg[idx].l, s, (s + e) / 2, x, y);
    } else {
      update(seg[idx].r, (s + e) / 2 + 1, e, x, y);
    }
    seg[idx].mn = min(seg[seg[idx].l].mn, seg[seg[idx].r].mn);
  }
} Seg;
long long tree[MAX_N + 1];
long long S;
void Add(int x, long long y) {
  while (x <= N) {
    tree[x] += y;
    x += (x & -x);
  }
}
long long Sum1(int x) {
  long long ret = 0;
  while (x > 0) {
    ret += tree[x];
    x -= (x & -x);
  }
  return ret;
}
long long Sum(int x, int y) { return Sum1(y) - Sum1(x - 1); }
int main() {
  scanf("%d", &N);
  Seg.Init(N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &arr[i]);
  }
  for (int i = 1; i <= N; i++) {
    Mn[i] = INFLL;
    scanf("%lld", &cost[i]);
  }
  scanf("%d", &M);
  for (int i = 1; i <= M; i++) {
    scanf("%d", &b[i]);
    idx[b[i]] = i;
  }
  bool tf = false;
  for (int i = 1; i <= N; i++) {
    if (cost[i] < 0) {
      Seg.Add(arr[i], N, cost[i]);
    }
    if (idx[arr[i]] == 0) {
      Add(arr[i], (long long)cost[i]);
      continue;
    }
    int ind = idx[arr[i]];
    if (ind == 1) {
      if (ind == M) tf = true;
      Seg.Update(arr[i], Sum(1, b[ind]));
    } else {
      if (Seg.Mn(b[ind - 1]) != INFLL) {
        if (ind == M) tf = true;
        Seg.Update(arr[i], Sum(b[ind - 1] + 1, b[ind]) + Seg.Mn(b[ind - 1]));
      }
    }
    Add(arr[i], (long long)cost[i]);
  }
  if (!tf) {
    printf("NO");
    return 0;
  }
  printf("YES\n");
  printf("%lld", Seg.Mn(b[M]) + ((b[M] != N) ? Sum(b[M] + 1, N) : 0LL));
  return 0;
}