#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2 * 1e5;
vector<int> gr[SIZE];
struct node {
  long long cnt;
  long long max_leaf;
  long long sum;
};
void DFS(int n, vector<node> &nodes) {
  for (auto x : gr[n]) {
    DFS(x, nodes);
    nodes[n].cnt += nodes[x].cnt;
    nodes[n].max_leaf = max(nodes[n].max_leaf, nodes[x].max_leaf);
    nodes[n].sum += nodes[x].sum;
  }
  if (gr[n].size() == 0) {
    nodes[n].cnt = 1;
    nodes[n].max_leaf = nodes[n].sum;
    return;
  }
  long long temp = ((nodes[n].sum + nodes[n].cnt - 1) / nodes[n].cnt);
  nodes[n].max_leaf = max(nodes[n].max_leaf, temp);
}
int main() {
  int n;
  cin >> n;
  vector<node> nodes(n);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    gr[a].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    nodes[i].sum = a;
    nodes[i].max_leaf = 0;
    nodes[i].cnt = 0;
  }
  DFS(0, nodes);
  cout << nodes[0].max_leaf << endl;
}
