#include <bits/stdc++.h>
using namespace std;
int fa[100010], s[100010], deg[100010];
int main() {
  int n, i;
  cin >> n;
  deg[1] = 1;
  for (i = 2; i <= n; i++) {
    cin >> fa[i];
    deg[i] = deg[fa[i]] + 1;
  }
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    if (s[i] == -1) s[i] = 1e9 + 1;
  }
  long long ans = 0;
  for (i = 2; i <= n; i++)
    if (deg[i] % 2) s[fa[i]] = min(s[fa[i]], s[i]);
  for (i = 1; i <= n; i++) {
    if (s[i] < s[fa[i]]) {
      ans = -1;
      break;
    }
    if (s[i] == 1e9 + 1) continue;
    ans += s[i] - s[fa[i]];
  }
  cout << ans << endl;
}
