#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> lst[100005];
long long m[100005];
long long cur[100005], sum[100005];
long long val[100005], res;
const long long INF = 1e9 + 7;
long long dfs(int v) {
  long long ret = INF;
  ret = min(ret, m[v]);
  for (int i = 0; i < lst[v].size(); i++) {
    int nxt = lst[v][i];
    ret = min(ret, dfs(nxt));
  }
  val[v] = ret;
  return ret;
}
void pro(int v) {
  long long ret = INF;
  if (m[v] == INF) {
    if (val[v] != INF) {
      if (val[v] - cur[v] >= 0) {
        res += val[v] - cur[v];
        cur[v] = val[v];
      } else {
        printf("-1");
        exit(0);
      }
    }
  } else {
    if (m[v] - cur[v] < 0) {
      printf("-1");
      exit(0);
    }
    res += m[v] - cur[v];
    cur[v] = m[v];
  }
  for (int i = 0; i < lst[v].size(); i++) {
    int nxt = lst[v][i];
    cur[nxt] = cur[v];
    pro(nxt);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    lst[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &m[i]);
    if (m[i] == -1) m[i] = INF;
  }
  dfs(1);
  pro(1);
  printf("%lld", res);
  return 0;
}
