#include <bits/stdc++.h>
using namespace std;
void dfs(vector<long long> g[], long long s, vector<long long> &ar,
         vector<long long> &dp, vector<long long> &cnt,
         vector<long long> &sum) {
  sum[s] = ar[s];
  if (!signed(g[s].size())) cnt[s] = 1;
  for (auto i : g[s]) {
    dfs(g, i, ar, dp, cnt, sum);
    cnt[s] += cnt[i];
    sum[s] += sum[i];
    dp[s] = max(dp[s], dp[i]);
  }
  dp[s] = max(dp[s], sum[s] / cnt[s] + ((sum[s] % cnt[s]) > 0));
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> g[n + 1];
  vector<long long> ar(n + 1, 0);
  for (long long i = 1; i <= n - 1; i++) {
    long long p;
    cin >> p;
    g[p].emplace_back(i + 1);
  }
  for (long long i = 1; i <= n; i++) cin >> ar[i];
  vector<long long> dp(n + 1, 0);
  vector<long long> cnt(n + 1, 0);
  vector<long long> sum(n + 1, 0);
  dfs(g, 1, ar, dp, cnt, sum);
  cout << dp[1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) solve();
  return 0;
}
