#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long N = 2e5 + 5;
const int mod = 1e9 + 7;
vector<long long> adj[N], leaf(N), sum(N), value(N);
void dfs(int beta, int baap) {
  if (((int)(adj[beta]).size()) == 0) {
    leaf[beta] = 1;
    sum[beta] = value[beta];
    return;
  }
  sum[beta] = value[beta];
  for (auto x : adj[beta]) {
    if (x != baap) {
      dfs(x, beta);
      leaf[beta] += leaf[x];
      sum[beta] += sum[x];
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  for (long long i = 2; i < n + 1; i++) {
    long long a;
    cin >> a;
    adj[a].push_back(i);
  }
  for (long long i = 1; i < n + 1; i++) {
    cin >> value[i];
  }
  dfs(1, 0);
  long long mx = 0;
  for (long long i = 1; i < n + 1; i++) {
    long long aa = sum[i], bb = leaf[i];
    mx = max(mx, (aa + bb - 1) / bb);
  }
  cout << mx;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
