#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > adj(100005);
long long sum[100005], arr[100005], ans, f = 0;
void dfs(long long curr, long long par, long long flag) {
  if (flag == 1) {
    for (int i = 0; i < (long long)adj[curr].size(); i++) {
      dfs(adj[curr][i], curr, 1 - flag);
    }
  } else {
    long long avail = sum[par];
    long long mn = 1e15;
    for (int i = 0; i < (long long)adj[curr].size(); i++) {
      mn = min(mn, sum[adj[curr][i]]);
    }
    if (mn != 1e15) {
      if (mn < avail) {
        f = 1;
      }
      mn -= avail;
      ans += mn;
      avail += mn;
    }
    for (int i = 0; i < (long long)adj[curr].size(); i++) {
      ans += sum[adj[curr][i]] - avail;
      dfs(adj[curr][i], curr, 1 - flag);
    }
  }
}
int main() {
  long long n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    long long par;
    cin >> par;
    adj[par].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    cin >> sum[i];
  }
  ans = sum[1];
  dfs(1, -1, 1);
  if (f == 1) {
    cout << "-1";
    return 0;
  }
  cout << ans << "\n";
}
