#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
long long n;
vector<int> adj[N];
long long a[N];
bool vis[N];
vector<long long> dfs(int node) {
  vis[node] = true;
  vector<long long> ret(3);
  long long leaf = 0, total = a[node], mx = 0, f = 1;
  for (auto to : adj[node]) {
    if (vis[to]) continue;
    f = 0;
    vector<long long> para;
    para = dfs(to);
    total += para[0], leaf += para[1], mx = max(mx, para[2]);
  }
  if (f) leaf++;
  long long now = max((long long)ceil(total / (double)leaf), mx);
  ret[0] = total, ret[1] = leaf, ret[2] = now;
  return ret;
}
void solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int in;
    cin >> in;
    in--;
    adj[in].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> ret = dfs(0);
  cout << ret[2] << "\n";
}
int main() {
  solve();
  return 0;
}
