#include <bits/stdc++.h>
using namespace std;
map<long long, long long> a;
map<long long, vector<long long>> adj;
long long cnt, mx;
pair<long long, long long> dfs(long long x) {
  if (adj[x].size() == 0) {
    mx = max(mx, (long long)a[x]);
    return {1, a[x]};
  }
  long long sum = 0, ct = 0;
  for (auto y : adj[x]) {
    pair<long long, long long> f = dfs(y);
    sum += f.second;
    ct += f.first;
  }
  sum += a[x];
  mx = max(mx, (sum + ct - 1) / ct);
  return {ct, sum};
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long x;
    cin >> x;
    adj[x].push_back(i);
  }
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    a[i] += x;
  }
  dfs(1);
  cout << mx << endl;
}
