#include <bits/stdc++.h>
using namespace std;
long long n, flag;
vector<vector<long long>> L;
vector<long long> colr;
long long dfs2(long long u = 1) {
  long long tt = colr[u], mx = 0;
  for (auto i : L[u]) {
    mx = max(mx, dfs2(i));
  }
  return tt + mx;
}
long long dfs(long long val, long long u = 1) {
  long long rem = val - colr[u];
  long long temp = 0;
  for (auto i : L[u]) {
    temp = 1;
    if (temp) break;
  }
  if (temp) {
    rem = -colr[u];
    for (auto i : L[u]) {
      rem += dfs(val, i);
    }
  }
  if (rem < 0) {
    flag = 1;
  }
  return rem;
}
int main() {
  cin >> n;
  L.resize(n + 1);
  colr.resize(n + 1);
  for (long long i = 0; i < n - 1; i++) {
    long long u;
    cin >> u;
    L[u].push_back(i + 2);
  }
  for (long long i = 1; i < n + 1; i++) {
    cin >> colr[i];
  }
  long long low = 0, high = dfs2(1);
  long long ans = high;
  while (low <= high) {
    long long mid = (low + high) >> 1;
    flag = 0;
    dfs(mid, 1);
    if (!flag) {
      ans = min(ans, mid);
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
