#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
vector<int> adj[MAXN];
unsigned long long people[MAXN], sum[MAXN] = {0}, children[MAXN] = {0}, n;
unsigned long long dfs(unsigned long long vertex, unsigned long long parent) {
  unsigned long long max_path = 0;
  for (int next : adj[vertex]) {
    if (next != parent) {
      max_path = max(max_path, dfs(next, vertex));
      sum[vertex] += sum[next];
      children[vertex] += children[next];
    }
  }
  sum[vertex] += people[vertex];
  if (children[vertex] == 0) {
    children[vertex]++;
    max_path = sum[vertex];
  } else {
    unsigned long long op =
        (sum[vertex] + (children[vertex] - 1)) / children[vertex];
    max_path = max(max_path, op);
  }
  return max_path;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    adj[a - 1].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    cin >> people[i];
  }
  cout << dfs(0, -1);
}
