#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int val[100005], par[100005];
int ans[100005];
void dfs(int x = 1, int dep = 1) {
  if (x == 1)
    ans[x] = val[x];
  else if (val[x] == -1)
    ans[x] = 0, val[x] = val[par[x]];
  else
    ans[x] = val[x] - val[par[x]];
  int mn = 1000000005;
  for (int i = 0; i < adj[x].size(); i++) {
    dfs(adj[x][i], dep + 1);
    mn = min(mn, ans[adj[x][i]]);
  }
  if (dep % 2 == 0 && mn != 1000000005) {
    ans[x] += mn;
    val[x] += mn;
    for (int i = 0; i < adj[x].size(); i++) {
      ans[adj[x][i]] -= mn;
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    adj[x].push_back(i);
    par[i] = x;
  }
  for (int i = 1; i <= n; i++) cin >> val[i];
  dfs();
  long long int ansr = 0;
  for (int i = 1; i <= n; i++) {
    if (ans[i] < 0) {
      cout << "-1" << endl;
      return 0;
    }
    ansr += ans[i];
  }
  cout << ansr << endl;
  return 0;
}
