#include <bits/stdc++.h>
using namespace std;
int n;
const int S = 2e5 + 5;
vector<int> adj[S];
vector<long long int> a(S), l(S, 0), sum(S, 0);
long long int ans = 0;
void dfs(int idx, int p) {
  int co = 0;
  for (auto x : adj[idx]) {
    if (x == p) continue;
    co++;
    dfs(x, idx);
    l[idx] += l[x];
    sum[idx] += sum[x];
  }
  if (!co) l[idx]++;
  ans = max(ans, (sum[idx] + l[idx] - 1) / l[idx]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    y = i + 2;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  for (int i = 1; i < n + 1; i++) cin >> sum[i];
  dfs(1, -1);
  cout << ans << '\n';
}
