#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double eps = 1e-6;
template <typename t>
void read(t &x) {
  char ch = getchar();
  x = 0;
  int f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  x = x * f;
}
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
vector<int> g[maxn];
long long a[maxn], v[maxn], le[maxn];
void dfs(int k, int last) {
  if (g[k].size() == 1 && k != 1) {
    v[k] = a[k];
    a[k] = 0;
    le[k] = 1;
    return;
  } else {
    for (int i = 0; i < g[k].size(); ++i) {
      if (g[k][i] != last) {
        dfs(g[k][i], k);
        v[k] = max(v[g[k][i]], v[k]);
        le[k] += le[g[k][i]];
      }
    }
    for (int i = 0; i < g[k].size(); ++i) {
      if (g[k][i] != last) {
        a[k] += a[g[k][i]];
        a[k] -= (v[k] - v[g[k][i]]) * le[g[k][i]];
      }
    }
    if (a[k] > 0) {
      v[k] += a[k] / le[k];
      a[k] %= le[k];
      if (a[k] > 0) {
        a[k] -= le[k];
        v[k]++;
      }
    }
  }
}
int main() {
  int n;
  read(n);
  int cnt = 0;
  for (int i = 2; i <= n; ++i) {
    int num;
    read(num);
    g[num].push_back(i);
    g[i].push_back(num);
  }
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  dfs(1, 1);
  printf("%lld\n", v[1]);
  return 0;
}
