#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int maxn = 1e5 + 10;
vector<int> adj[maxn];
long long sum[maxn], ans, flag;
void dfs(int u, long long pre, bool opt) {
  if (opt) {
    if (sum[u] < 0 || sum[u] - pre < 0) {
      flag = 0;
      return;
    }
    ans += sum[u] - pre;
    for (int i = 0; i < adj[u].size(); i++) dfs(adj[u][i], sum[u], !opt);
    return;
  }
  long long cur = inf;
  for (int i = 0; i < adj[u].size(); i++) cur = min(cur, sum[adj[u][i]] - pre);
  if (cur < 0) {
    flag = 0;
    return;
  }
  if (cur == inf) cur = 0;
  ans += cur;
  for (int i = 0; i < adj[u].size(); i++) dfs(adj[u][i], pre + cur, !opt);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    adj[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &sum[i]);
  flag = 1;
  dfs(1, 0, 1);
  if (!flag)
    printf("-1");
  else
    printf("%lld", ans);
  return 0;
}
