#include <bits/stdc++.h>
using namespace std;
const long long int M = 1000000007;
long long int ncr(int n, int r) {
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  long long int ans = 1;
  int i;
  for (i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }
  return ans;
}
long long int power(long long int x, long long int n, long long int m) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return (power(((x % m) * (x % m)) % m, n / 2, m)) % m;
  else
    return ((x % m) * (power(x, n - 1, m) % m)) % m;
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
string binary(long long int n) {
  if (n == 0) return "0";
  string ans;
  while (n > 0) {
    if (n & 1)
      ans.push_back('1');
    else
      ans.push_back('0');
    n = n >> 1;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
bool is_prime(long long int n) {
  if (n == 1) return 0;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long int sum_digit(long long int n) {
  long long int ans = 0;
  while (n > 0) {
    ans += (n % 10);
    n /= 10;
  }
  return ans;
}
long long int len_digit(long long int n) {
  long long int ans = 0;
  while (n > 0) {
    ans += 1;
    n /= 10;
  }
  return ans;
}
long long int binary_to_decimal(string str) {
  long long int ans = 0, d = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += d * (str[i] - 48);
    d *= 2;
  }
  return ans;
}
double round(double var) {
  double value = (long long int)(var * 100 + .5);
  return (double)value / 100;
}
long long int n;
long long int par[100001], sum[100001], level[100001], a[100001], vis[100001],
    val[100001];
vector<long long int> adj[100001];
void dfs(long long int n, long long int l, long long int par1) {
  vis[n] = 1;
  level[n] = l;
  par[n] = par1;
  for (int i = 0; i < adj[n].size(); i++) {
    if (vis[adj[n][i]] == 0) dfs(adj[n][i], l + 1, n);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  long long int x;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    adj[i].push_back(x);
    adj[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) cin >> sum[i];
  long long int f = 0;
  dfs(1, 1, 0);
  for (int i = 2; i <= n; i++) {
    if (level[i] & 1) {
      long long int f1 = sum[i] - sum[par[par[i]]];
      val[i] = f1;
      if (f1 < 0) f += 1;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (level[i] % 2 == 0) {
      long long int d = 1000000000000000000;
      for (int j = 0; j < adj[i].size(); j++) {
        if (adj[i][j] != par[i]) d = min(d, val[adj[i][j]]);
      }
      if (d == 1000000000000000000) d = 0;
      a[i] = d;
    }
  }
  long long int ans = sum[1];
  for (int i = 2; i <= n; i++) {
    if (level[i] & 1) {
      long long int v = sum[i] - sum[par[par[i]]] - a[par[i]];
      if (v < 0) f += 1;
      ans += v;
    } else {
      ans += a[i];
    }
  }
  if (f > 0) {
    cout << "-1";
  } else {
    cout << ans;
  }
  return 0;
}
