#include <bits/stdc++.h>
using namespace std;
long long p1 = 1000000, p2 = 0;
char buf[1000005], wb[1000005];
long long getint() {
  long long ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    ret = (ret << 3) + (ret << 1) + c - '0';
    c = getchar();
  }
  return ret * flag;
}
void pc(char x) {
  if (p2 >= 1000000) fwrite(wb, 1, 1000000, stdout), p2 = 0;
  wb[p2++] = x;
}
void wrt(long long x) {
  if (x < 0) pc('-'), x = -x;
  long long c[24] = {0};
  if (!x) return pc('0'), void();
  while (x) c[++c[0]] = x % 10, x /= 10;
  while (c[0]) pc(c[c[0]--] + '0');
}
long long n;
struct edge {
  long long ne, v;
} e[400005];
long long head[200005], cnt;
void add(long long u, long long v) {
  ++cnt;
  e[cnt].v = v;
  e[cnt].ne = head[u];
  head[u] = cnt;
}
long long w[200005], sz[200005], sw[200005];
long long val[200005], sy[200005];
void dfs(long long x, long long prt) {
  if (!head[x]) {
    sy[x] = 0;
    sz[x] = 1;
  }
  sw[x] = w[x];
  for (long long i = head[x]; i; i = e[i].ne) {
    long long y = e[i].v;
    if (y == prt) continue;
    dfs(y, x);
    sw[x] += sw[y];
    sz[x] += sz[y];
    sy[x] += sy[y];
    val[x] = max(val[x], val[y]);
  }
  for (long long i = head[x]; i; i = e[i].ne) {
    long long y = e[i].v;
    if (y == prt) continue;
    sy[x] += (val[x] - val[y]) * sz[y];
  }
  long long num = min(sy[x], w[x]);
  w[x] -= num, sy[x] -= num;
  if (w[x]) {
    if (w[x] % sz[x] == 0)
      val[x] = val[x] + w[x] / sz[x], sy[x] = 0;
    else
      val[x] = val[x] + w[x] / sz[x] + 1, sy[x] = val[x] * sz[x] - sw[x];
  }
}
int main() {
  n = getint();
  for (long long i = 2; i <= n; i++) {
    long long p = getint();
    add(p, i);
  }
  for (long long i = 1; i <= n; i++) w[i] = getint();
  dfs(1, 1);
  wrt(val[1]);
  fwrite(wb, 1, p2, stdout);
  return 0;
}
