#include <bits/stdc++.h>
using namespace std;
const long long N = 1e7 + 1;
vector<vector<long long>> v(100001);
vector<long long> sum(100001), par(100001), level(100001), value(100001);
bool bfs(long long x) {
  queue<long long> q;
  q.push(x);
  value[x] = sum[x];
  while (!q.empty()) {
    long long k = q.front();
    q.pop();
    for (long long i = 0; i < v[k].size(); i++) {
      q.push(v[k][i]);
      level[v[k][i]] = level[k] + 1;
      if (level[v[k][i]] % 2 == 0) {
        long long mi = 10000000000;
        for (auto X : v[v[k][i]]) {
          mi = min(mi, sum[X]);
        }
        if (mi == 10000000000) {
          sum[v[k][i]] = sum[par[v[k][i]]];
          value[v[k][i]] = 0;
        } else {
          value[v[k][i]] = mi - sum[par[v[k][i]]];
          sum[v[k][i]] = sum[par[v[k][i]]] + value[v[k][i]];
        }
      } else {
        value[v[k][i]] = sum[v[k][i]] - sum[par[v[k][i]]];
      }
      if (value[v[k][i]] < 0) return false;
    }
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, ans = 0, x;
  cin >> n;
  for (long long i = 2; i < n + 1; i++) {
    cin >> x;
    par[i] = x;
    v[x].push_back(i);
  }
  for (long long i = 1; i < n + 1; i++) cin >> sum[i];
  level[1] = 1;
  bool p = bfs(1);
  if (!p)
    cout << "-1";
  else {
    for (long long i = 1; i < n + 1; i++) ans += value[i];
    cout << ans;
  }
}
