#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> v(n + 1);
  vector<vector<long long>> adj(n + 1);
  for (long long i = 2; i <= n; i++) {
    long long x;
    cin >> x;
    adj[x].push_back(i);
  }
  for (long long i = 1; i <= n; i++) cin >> v[i];
  vector<long long> mn(n + 1);
  for (long long i = 1; i <= n; i++) {
    if (adj[i].size() != 0) {
      long long c = 1e9;
      for (auto k : adj[i]) c = min(c, v[k]);
      mn[i] = max(0LL, c);
    }
  }
  queue<long long> q;
  vector<long long> dis(n + 1), sum(n + 1);
  q.push(1);
  sum[1] = v[1];
  dis[1] = 1;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (auto x : adj[u]) {
      if (dis[u] % 2) {
        v[x] = max(0LL, mn[x] - sum[u]);
        sum[x] = sum[u] + v[x];
      } else {
        if (v[x] < sum[u]) {
          cout << -1;
          return 0;
        }
        sum[x] = v[x];
        v[x] -= sum[u];
      }
      q.push(x);
      dis[x] = dis[u] + 1;
    }
  }
  long long ans = 0;
  for (auto p : v) ans += p;
  cout << ans;
}
