#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int MAXM = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3f;
const int NINF = -INF - 1;
const long long int mod = 1e9 + 7;
long long int head[MAXN], tot, n, sum[MAXN], leaf[MAXN];
long long int a[MAXN];
struct Edge {
  long long int next, to;
} edge[MAXM];
void add(long long int x, long long int y) {
  edge[tot].to = y;
  edge[tot].next = head[x];
  head[x] = tot++;
}
long long int ans;
void dfs(long long int u) {
  if (head[u] == -1) leaf[u] = 1;
  sum[u] = a[u];
  for (long long int i = head[u]; ~i; i = edge[i].next) {
    long long int ver = edge[i].to;
    dfs(ver);
    sum[u] += sum[ver];
    leaf[u] += leaf[ver];
  }
  ans = max(ans, (long long int)ceil(1.0 * sum[u] / leaf[u]));
  return;
}
int main() {
  scanf("%lld", &n);
  memset(head, -1, sizeof(head));
  tot = 0;
  for (long long int i = 2; i <= n; i++) {
    long long int x;
    scanf("%lld", &x);
    add(x, i);
  }
  for (long long int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  ans = 0;
  dfs(1);
  cout << ans << endl;
  return 0;
}
