#include <bits/stdc++.h>
using namespace std;
vector<long long> arr;
vector<long long> tree;
vector<int> child;
vector<vector<int> > adj;
long long mx = 0;
void dfs(int node, int parent) {
  tree[node] += arr[node];
  int cnt = 0;
  for (auto var : adj[node]) {
    if (var != parent) {
      dfs(var, node);
      tree[node] += tree[var];
      child[node] += child[var];
      cnt++;
    }
  }
  if (cnt == 0) child[node]++;
}
int main() {
  int n;
  cin >> n;
  adj.resize(n + 1);
  for (int i = 2; i <= n; i++) {
    int a;
    cin >> a;
    adj[a].push_back(i);
    adj[i].push_back(a);
  }
  arr.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> arr[i];
  tree.resize(n + 1);
  child.resize(n + 1);
  dfs(1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long temp = tree[i] / child[i];
    if (tree[i] % child[i]) temp++;
    ans = max(ans, temp);
  }
  cout << ans;
  return 0;
}
