#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int32_t MOD = 1e9 + 7;
const long long N = 2e5 + 5;
vector<long long> edge[N];
long long a[N];
long long n;
long long dp[N], sum[N], nl[N];
void dfs(long long v, long long par) {
  sum[v] = a[v];
  nl[v] = !(edge[v].size());
  dp[v] = 0;
  for (auto cur : edge[v]) {
    if (cur != par) {
      dfs(cur, v);
      sum[v] += sum[cur];
      nl[v] += nl[cur];
      dp[v] = max(dp[v], dp[cur]);
    }
  }
  dp[v] = max(dp[v], (sum[v] + nl[v] - 1) / (nl[v]));
}
void solve() {
  cin >> n;
  for (long long i = 1; i < n; ++i) {
    long long x;
    cin >> x;
    edge[x].push_back(i + 1);
  }
  for (long long i = 1; i < n + 1; i++) cin >> a[i];
  dfs(1, -1);
  cout << dp[1] << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
