#include <bits/stdc++.h>
using namespace std;
vector<long long int> edges[2000007];
long long int dp[2000007], sum[2000007], child[2000007], a[2000007];
void dfs(long long int u) {
  if (edges[u].size() == 0) child[u] = 1;
  sum[u] = a[u];
  for (long long int v : edges[u]) {
    dfs(v);
    sum[u] += sum[v];
    child[u] += child[v];
    dp[u] = max(dp[u], dp[v]);
  }
  dp[u] = max(dp[u], (sum[u] + child[u] - 1) / child[u]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n, x;
  cin >> n;
  for (long long int i = 2; i <= n; i++) cin >> x, edges[x].push_back(i);
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  dfs(1);
  cout << dp[1] << endl;
  return 0;
}
