#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int p[n + 1], s[n];
  p[0] = 0;
  p[1] = -1;
  int i = 0;
  for (i = 2; i <= n; i++) {
    cin >> p[i];
  }
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  long long int d = 1;
  vector<vector<int>> v;
  v.resize(n + 1);
  for (i = 2; i <= n; i++) {
    v[p[i]].push_back(i);
  }
  long long int j = 0;
  long long int sum = 0, x = 0, sum1 = 0, mini = 0;
  queue<long long int> q;
  q.push(1);
  q.push(-1);
  while (!q.empty()) {
    x = q.front();
    if (d % 2 == 1) {
      while (x != -1) {
        q.pop();
        for (i = 0; i < v[x].size(); i++) {
          q.push(v[x][i]);
        }
        x = q.front();
      }
      q.pop();
      if (!q.empty()) {
        q.push(-1);
      }
    } else {
      while (x != -1) {
        q.pop();
        if (v[x].size() != 0) {
          mini = s[v[x][0] - 1];
          for (i = 0; i < v[x].size(); i++) {
            if (s[v[x][i] - 1] < mini) {
              mini = s[v[x][i] - 1];
            }
            q.push(v[x][i]);
          }
          s[x - 1] = mini;
        } else {
          s[x - 1] = s[p[x] - 1];
        }
        x = q.front();
      }
      sum1 = q.front();
      q.pop();
      if (!q.empty()) {
        q.push(-1);
      }
    }
    d++;
  }
  sum = s[0];
  for (i = 1; i < n; i++) {
    if (s[i] - s[p[i + 1] - 1] < 0) {
      sum = -1;
      break;
    }
    sum += s[i] - s[p[i + 1] - 1];
  }
  cout << sum << endl;
  return 0;
}
