#include <bits/stdc++.h>
using namespace std;
inline long long Read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long first[1000005], nxt[1000005], to[1000005], tot = 0;
void Add(long long x, long long y) {
  nxt[++tot] = first[x];
  first[x] = tot;
  to[tot] = y;
}
long long n, fa[1000005], num[1000005], f[1000005];
void dfs(long long u) {
  long long flag = 0;
  for (long long e = first[u]; e; e = nxt[e]) {
    flag = 1;
    long long v = to[e];
    dfs(v);
    num[u] += num[v];
    f[u] += f[v];
  }
  if (!flag) f[u] = 1;
}
signed main() {
  n = Read();
  for (long long i = 2; i <= n; i++) fa[i] = Read(), Add(fa[i], i);
  for (long long i = 1; i <= n; i++) num[i] = Read();
  dfs(1);
  long long ans = 0;
  for (long long i = 1; i <= n; i++)
    ans = max(ans, num[i] / f[i] + (num[i] % f[i] != 0));
  cout << ans << endl;
  return 0;
}
