#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
vector<int> adj[maxn];
int lev[maxn], a[maxn];
long long sum[maxn], ans;
void dfs(int u = 0) {
  sum[u] = a[u];
  lev[u] = (adj[u].size() ? 0 : 1);
  for (int v : adj[u]) {
    dfs(v);
    sum[u] += sum[v];
    lev[u] += lev[v];
  }
  ans = max(ans, (sum[u] + lev[u] - 1ll) / lev[u]);
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    --p;
    adj[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  dfs();
  cout << ans << '\n';
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
