#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  T res = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    res = (res << 3) + (res << 1) + c - '0';
    c = getchar();
  }
  x = res * f;
}
void print(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
long long n, p, a[maxn], sum[maxn], zs[maxn], mx[maxn], du[maxn];
vector<long long> g[maxn];
bool f = false;
void dfs(long long x) {
  for (auto i : g[x]) {
    dfs(i);
    sum[x] += sum[i];
    zs[x] += zs[i];
  }
}
int main() {
  long long _s = 1;
  for (long long _ = 1; _ <= _s; _++) {
    read(n);
    for (long long i = 2; i <= n; i++) {
      read(p);
      g[p].push_back(i);
      du[p]++;
    }
    for (long long i = 1; i <= n; i++) {
      if (du[i] == 0) zs[i] = 1;
      read(sum[i]);
    }
    dfs(1);
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      long long t = (sum[i] % zs[i] == 0) ? 0 : 1;
      long long c = sum[i] / zs[i] + t;
      ans = max(ans, c);
    }
    cout << ans;
  }
  return 0;
}
