#include <bits/stdc++.h>
using namespace std;
vector<long long> chi[100001];
long long val[100001];
bool f = 1;
long long ans;
void dfs(long long, long long, bool);
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long x;
  for (long long i = 2; i <= n; i++) {
    cin >> x;
    chi[x].push_back(i);
  }
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    val[i] = x;
    if (val[i] == -1) val[i] = LLONG_MAX;
  }
  ans = val[1];
  dfs(1, 0, 1);
  cout << (f ? ans : -1);
}
void dfs(long long v, long long m, bool h) {
  if (val[v] < m) {
    f = 0;
    return;
  }
  if (h) {
    for (auto x : chi[v]) {
      dfs(x, val[v], h ^ 1);
    }
  } else {
    vector<long long> hehe;
    long long ma = LLONG_MAX;
    for (auto x : chi[v]) {
      hehe.push_back(val[x]);
      ma = min(ma, val[x]);
      dfs(x, m, h ^ 1);
    }
    if (ma != LLONG_MAX) ans += ma - m;
    for (auto x : hehe) {
      ans += x - ma;
    }
  }
}
