#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6;
long long ren[maxn], fu[maxn];
long long head[maxn], nxt[maxn], cnt = 0, to[maxn], ww[maxn];
int vis[maxn];
long long sum[maxn], zi[maxn];
void add(long long x, long long y, long long w) {
  nxt[++cnt] = head[x], to[cnt] = y, ww[cnt] = w, head[x] = cnt;
}
void dfs(long long u) {
  int flag = 0;
  sum[u] = ren[u];
  for (int i = head[u]; i; i = nxt[i]) {
    long long v = to[i];
    dfs(v);
    flag = 1;
    zi[u] += zi[v];
    sum[u] += sum[v];
  }
  if (flag == 0) zi[u] = 1;
}
int main() {
  long long n;
  scanf("%lld", &n);
  cnt = 0;
  for (int i = 2; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    add(x, i, 0);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &ren[i]);
  }
  dfs(1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, sum[i] / zi[i] + (sum[i] % zi[i] != 0));
  }
  printf("%lld\n", ans);
  return 0;
}
