#include <bits/stdc++.h>
using namespace std;
long long nCrModpDP(long long n, long long r, long long p) {
  long long C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
long long nCrModpLucas(long long n, long long r, long long p) {
  if (r == 0 || n == 0) return 1;
  long long ni = n % p, ri = r % p;
  return (nCrModpLucas(n / p, r / p, p) * nCrModpDP(ni, ri, p)) % p;
}
vector<long long> a[200004];
long long sum[200005];
long long cnt[200005];
long long ans[200005];
void dfs(long long node) {
  if (a[node].empty()) cnt[node] = 1;
  for (auto child : a[node]) {
    dfs(child);
    sum[node] += sum[child];
    cnt[node] += cnt[child];
    ans[node] = max(ans[node], ans[child]);
  }
  ans[node] = max(ans[node], (sum[node] + cnt[node] - 1) / cnt[node]);
}
int main() {
  memset(sum, 0, sizeof(sum));
  memset(cnt, 0, sizeof(cnt));
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long x;
    cin >> x;
    a[x].push_back(i + 2);
  }
  for (long long i = 0; i < n + 1; i++) {
    if (i != 0) cin >> sum[i];
  }
  dfs(1);
  cout << ans[1];
  return 0;
}
