#include <bits/stdc++.h>
const int MAX = 2 * 1e5 + 2, MOD = 1e9 + 7;
using namespace std;
int n, a[MAX], s[MAX], p, mn = 1e9;
vector<int> v[MAX];
void dfs(int root, int pa, int depth) {
  if (depth == 1)
    a[root] = s[root] - s[pa];
  else if (depth == 0 && v[root].size() == 1)
    a[root] = 0, s[root] = s[pa];
  else {
    mn = 1e9;
    for (int x : v[root]) {
      if (x != pa) mn = min(mn, s[x] - s[pa]);
    }
    a[root] = mn;
    s[root] = a[root] + s[pa];
  }
  if (v[root].size() > 0)
    for (int x : v[root]) {
      if (x != pa) dfs(x, root, 1 - depth);
    }
}
int main() {
  s[0] = 0;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%i", &p);
    v[i + 1].push_back(p);
    v[p].push_back(i + 1);
  }
  for (int i = 1; i <= n; i++) scanf("%i", &s[i]);
  dfs(1, 0, 1);
  for (int i = 1; i <= n; i++)
    if (a[i] < 0) {
      cout << -1;
      return 0;
    }
  long long sum = 0;
  for (int i = 1; i <= n; i++) sum += (long long)a[i];
  cout << sum;
  return 0;
}
