#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
template <typename T>
inline void read(T &x) {
  x = 0;
  char ch = getchar();
  bool f = false;
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = f ? -x : x;
}
template <typename T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 ^ 48);
}
int head[MAXN], nex[MAXN];
int ver[MAXN];
int tot;
int vis[MAXN];
long long maxn[MAXN], sum[MAXN], cnt[MAXN];
inline void add(int x, int y) {
  nex[++tot] = head[x];
  head[x] = tot;
  ver[tot] = y;
}
inline void dfs(int x) {
  for (int i = head[x]; i; i = nex[i]) {
    int y = ver[i];
    dfs(y);
    cnt[x] += cnt[y];
    maxn[x] = max(maxn[x], maxn[y]);
    sum[x] += sum[y];
  }
  maxn[x] = max(maxn[x], (sum[x] + cnt[x] - 1) / cnt[x]);
}
int n;
int main() {
  read(n);
  for (int y = 2; y <= n; y++) {
    int x;
    read(x);
    add(x, y);
    vis[x] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) cnt[i] = 1ll;
  for (int i = 1; i <= n; i++) read(sum[i]);
  dfs(1);
  print(maxn[1]);
  return 0;
}
