#include <bits/stdc++.h>
using namespace std;
long long wl, n, a[200010], x, y, head[200010], lf[200010], sum_lf[200010],
    mx_lf[200010];
struct node {
  long long nxt, to;
} star[200010];
inline void add(long long from, long long to) {
  wl++;
  star[wl].to = to;
  star[wl].nxt = head[from];
  head[from] = wl;
}
inline void dfs(long long x, long long fa) {
  if (!head[x]) {
    lf[x]++;
    sum_lf[x] = a[x];
    mx_lf[x] = max(mx_lf[x], a[x]);
    return;
  }
  sum_lf[x] = a[x];
  for (register long long i = head[x]; i; i = star[i].nxt) {
    long long u = star[i].to;
    dfs(u, x);
    lf[x] += lf[u];
    sum_lf[x] += sum_lf[u];
    mx_lf[x] = max(mx_lf[x], mx_lf[u]);
  }
  mx_lf[x] = max((sum_lf[x] + lf[x] - 1) / lf[x], mx_lf[x]);
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (register long long i = 1; i < n; ++i) {
    long long s;
    cin >> s;
    add(s, i + 1);
  }
  for (register long long i = 1; i <= n; ++i) cin >> a[i];
  dfs(1, 0);
  cout << mx_lf[1];
}
