#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
const long long INF = 2e9, INFLL = 1e18, MOD = 1e9 + 7;
void dfs(long long nod, vector<long long> &ar, vector<long long> &c,
         vector<long long> &ch, vector<long long> &M,
         vector<vector<long long>> &g) {
  c[nod] = ar[nod];
  if (g[nod].size() == 0) ch[nod] = 1, M[nod] = ar[nod];
  for (auto i : g[nod]) {
    dfs(i, ar, c, ch, M, g);
    c[nod] += c[i];
    ch[nod] += ch[i];
    M[nod] = max(M[nod], M[i]);
  }
  M[nod] = max(M[nod], (c[nod] + ch[nod] - 1) / ch[nod]);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<vector<long long>> g(n);
  for (long long i = 1; i < n; i++) {
    long long a;
    cin >> a;
    g[a - 1].push_back(i);
  }
  vector<long long> ar(n);
  for (auto &i : ar) cin >> i;
  vector<long long> c(n), ch(n), M(n);
  dfs(0, ar, c, ch, M, g);
  cout << M[0];
  return 0;
}
