#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 2E5 + 100;
long long n;
long long s[MAX_N], sw[MAX_N], w[MAX_N], a[MAX_N];
vector<long long> G[MAX_N];
void dfs1(long long u) {
  s[u] = a[u];
  for (long long v : G[u]) {
    dfs1(v);
    w[u] += w[v];
    s[u] += s[v];
  }
  if (0 == G[u].size()) {
    w[u] = 1;
  }
}
void dfs2(long long u) {
  for (long long v : G[u]) dfs2(v);
  for (long long v : G[u]) {
    if (a[u] && s[v] - sw[v] * w[v] > 0) {
      if (a[u] >= s[v] - sw[v] * w[v]) {
        a[u] -= s[v] - sw[v] * w[v];
        s[v] = sw[v] * w[v];
      } else {
        s[v] += a[u];
        a[u] = 0;
      }
    }
    sw[u] = max(sw[u], sw[v]);
  }
  for (long long v : G[u]) {
    if (a[u] && sw[u] * w[v] - s[v] > 0) {
      if (a[u] >= sw[u] * w[v] - s[v]) {
        a[u] -= sw[u] * w[v] - s[v];
        s[v] = sw[u] * w[v];
      } else {
        s[v] += a[u];
        a[u] = 0;
      }
    }
  }
  sw[u] += a[u] / w[u] + (0 != a[u] % w[u]);
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 2; i <= n; ++i) {
    long long tmp;
    cin >> tmp;
    G[tmp].push_back(i);
  }
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  dfs1(1);
  dfs2(1);
  cout << sw[1] << endl;
  return 0;
}
