#include <bits/stdc++.h>
using namespace std;
int n, mus[100001], used[100001];
long long ans = 0;
bool mb = true;
vector<int> gr[100001];
void dfs(int edge, int parent, int deph) {
  int elem = 1000000001;
  if (deph % 2 == 0) {
    for (auto i : gr[edge]) {
      used[i] -= mus[parent];
      if (mus[i] < abs(used[i])) mb = false;
    }
    if (gr[edge].size() != 0) {
      for (auto i : gr[edge]) elem = min(mus[i] + used[i], elem);
      for (auto i : gr[edge]) used[i] -= elem;
      used[edge] = elem;
    }
  } else
    used[edge] += mus[edge];
  for (auto i : gr[edge]) dfs(i, edge, deph + 1);
}
int main() {
  cin >> n;
  int tmp;
  for (int i = 2; i <= n; i++) {
    cin >> tmp;
    gr[tmp].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> mus[i + 1];
  dfs(1, 1, 1);
  if (mb) {
    for (int i = 0; i < 100002; i++) {
      ans += used[i];
    }
    cout << ans;
  } else
    cout << -1;
  return 0;
}
