#include <bits/stdc++.h>
using namespace std;
vector<long long> edges[200005];
long long dp[200005];
long long sum[200005];
long long nleaf[200005];
long long n;
vector<int> a(200005);
void dfs(long long v, long long p) {
  nleaf[v] = !(edges[v].size());
  sum[v] = a[v];
  dp[v] = 0;
  for (long long x : edges[v])
    if (x != p) {
      dfs(x, v);
      nleaf[v] += nleaf[x];
      sum[v] += sum[x];
      dp[v] = max(dp[v], dp[x]);
    }
  dp[v] = max(dp[v], (sum[v] + nleaf[v] - 1) / nleaf[v]);
}
void solve(int tc = 0) {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    --x;
    edges[x].push_back(i + 1);
  }
  for (long long i = 0; i < n; i++) cin >> a[i];
  dfs(0, -1);
  cout << dp[0] << '\n';
}
int main() { solve(); }
