#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200001], dp[200001], c;
int f[200001];
vector<int> sn[200001];
bool chk(int x) {
  dp[x] = 0;
  for (int i = 0; i < sn[x].size(); i++) {
    if (chk(sn[x][i]) == false) return false;
    dp[x] += dp[sn[x][i]];
    if (dp[x] > 1000000000000000000ll) dp[x] = 1000000000000000000ll;
  }
  if (sn[x].size() == 0) dp[x] = c;
  dp[x] -= a[x];
  if (dp[x] < 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    f[i] = x;
    sn[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  long long l = 0ll, r = 200000000000000ll, ns = 0ll;
  while (l <= r) {
    c = (l + r) >> 1ll;
    if (chk(1)) {
      ns = c;
      r = c - 1ll;
      continue;
    }
    l = c + 1ll;
  }
  printf("%lld\n", ns);
  return 0;
}
