#include <bits/stdc++.h>
using namespace std;
const long long h = 3, ki = 3, mo = 998244353;
inline long long inc(long long x, long long k) {
  x += k;
  return x >= mo ? x - mo : x;
}
inline long long dec(long long x, long long k) {
  x -= k;
  return x < 0 ? x + mo : x;
}
inline long long read() {
  char ch = 0;
  long long x = 0, flag = 1;
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') flag = -1;
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  }
  return x * flag;
}
inline void write(long long x) {
  if (!x) return (void)putchar(48);
  if (x < 0) putchar(45), x = -x;
  long long len = 0, p[20];
  while (x) p[++len] = x % 10, x /= 10;
  for (long long i = len; i >= 1; i--) putchar(p[i] + 48);
}
const double eps = 1e-7, inf = 1e9 + 7, pi = acos(-1);
inline double Read() {
  double x;
  scanf("%lf", &x);
  return x;
}
inline void Write(double x) { printf("%lf", x); }
long long f[1100000], s[1100000], sz[1100000];
long long g(double a, double b) { return ceil(a / b); }
int main() {
  long long n = read(), ans = 0;
  for (long long i = 1; i <= n; i++) s[i] = 1;
  for (long long i = 2; i <= n; i++) {
    long long x = read();
    f[i] = x;
    s[x] = 0;
  }
  for (long long i = 1; i <= n; i++) sz[i] = read();
  for (long long i = n; i >= 1; i--)
    s[f[i]] += s[i], sz[f[i]] += sz[i], ans = max(ans, g(sz[i], s[i]));
  write(ans);
  return 0;
}
