#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAXN = 2e5 + 1;
long long fact[MAXN];
void calc_fact(long long n = MAXN - 1) {
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) fact[i] = (i * 1LL * fact[i - 1]) % MOD;
}
long long fast_pow(long long n, long long k) {
  long long res = 1;
  while (k > 0) {
    if (k % 2) res = (res * 1LL * n) % MOD;
    n = (n * 1LL * n) % MOD;
    k /= 2;
  }
  return res;
}
long long inv_mod(long long n) { return fast_pow(n, MOD - 2); }
long long ncr(long long n, long long k) {
  if (k > n) return 0;
  return ((fact[n] * 1LL * inv_mod(fact[k])) % MOD * inv_mod(fact[n - k])) %
         MOD;
}
void readArray(long long *nums, long long n) {
  for (long long i = 0; i < n; i++) cin >> nums[i];
}
void printArray(long long *nums, long long n) {
  for (long long i = 0; i < n; i++) cout << nums[i] << " ";
  cout << "\n";
}
void reader() {}
bool isPrime(long long n) {
  if (n <= 1) return false;
  for (long long i = 2; i < n; i++)
    if (n % i == 0) return false;
  return true;
}
vector<long long> adj[MAXN];
long long c[MAXN];
long long ss[MAXN];
long long l[MAXN];
long long ans = 0;
void dfs(long long cur, long long par) {
  l[cur] = 0;
  ss[cur] = c[cur];
  for (auto i : adj[cur]) {
    dfs(i, cur);
  }
  if (adj[cur].size() == 0) {
    l[cur]++;
  }
  l[par] += l[cur];
  ss[par] += ss[cur];
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long v;
    cin >> v;
    adj[v].push_back(i);
  }
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
  }
  dfs(1, -1);
  for (long long i = 1; i <= n; i++) {
    long long ans1 = (ss[i] / l[i]);
    if (ss[i] % l[i] != 0) ans1++;
    ans = max(ans, ans1);
  }
  cout << ans << "\n";
}
