#include <bits/stdc++.h>
using namespace std;
int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
struct Edge {
  int to, next;
} e[200010];
int h[200010], cnt, sz[200010], p[200010];
long long s[200010], mx[200010], a[200010];
void add(int x, int y) { e[++cnt] = (Edge){y, h[x]}, h[x] = cnt; }
void Dfs(int x) {
  for (int i = h[x]; i; i = e[i].next) {
    Dfs(e[i].to);
    sz[x] += sz[e[i].to];
    s[x] += s[e[i].to];
    mx[x] = max(mx[x], mx[e[i].to]);
  }
  s[x] += a[x];
  if (!sz[x]) return sz[x] = 1, mx[x] = a[x], void(0);
  if (s[x] > sz[x] * mx[x]) mx[x] += ceil(1. * (s[x] - sz[x] * mx[x]) / sz[x]);
}
signed main() {
  int n = read();
  for (int i = 2; i <= n; i++) add(p[i] = read(), i);
  for (int i = 1; i <= n; i++) a[i] = read();
  Dfs(1);
  printf("%lld\n", mx[1]);
  return 0;
}
