#include <bits/stdc++.h>
using namespace std;
vector<long long> tr[100005];
long long val[100005];
bool vis[100005];
long long ans = 0, flag = 0;
void dfs(long long at, long long from, long long dep) {
  vis[at] = 1;
  if (dep % 2 == 0) {
    long long mn = 1000000000000005;
    for (long long i = 0; i < (long long)tr[at].size(); i++) {
      long long v = tr[at][i];
      if (vis[v] == 0) {
        mn = min(mn, val[v]);
      }
    }
    if (mn < val[from]) {
      flag = 1;
      return;
    } else if (mn > 100000000000000) {
      val[at] = 0ll;
      return;
    } else {
      val[at] = val[from] + (mn - val[from]);
      ans += (val[at] - val[from]);
    }
  } else {
    ans += (val[at] - val[from]);
  }
  for (long long i = 0; i < (long long)tr[at].size(); i++) {
    long long v = tr[at][i];
    if (vis[v] == 0) {
      dfs(v, at, dep + 1);
    }
  }
  return;
}
int main() {
  long long n, p;
  scanf("%lld", &n);
  for (long long i = 2; i <= n; i++) {
    scanf("%lld", &p);
    tr[p].push_back(i);
    tr[i].push_back(p);
  }
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &val[i]);
  }
  val[0] = 0;
  dfs(1ll, 0ll, 1ll);
  if (flag) ans = -1ll;
  cout << ans << endl;
}
