#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e6 + 10;
const long long MOD = 998244353;
const long long INF = 1e9;
long long add(long long x, long long y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
long long mul(long long x, long long y) { return (x * 1ll * y) % MOD; }
long long binpow(long long x, long long y) {
  long long ans = 1;
  while (y > 0) {
    if (y % 2 == 1) ans = mul(ans, x);
    x = mul(x, x);
    y /= 2;
  }
  return ans;
}
long long divide(long long x, long long y) {
  return mul(x, binpow(y, MOD - 2));
}
long long sum[200001], leaf[200001];
long long dp[200001];
bool vis[200001];
void dfs(long long root, vector<vector<long long>> &adj, vector<long long> &v) {
  vis[root] = true;
  if (adj[root].size() == 0) leaf[root] = 1;
  sum[root] = v[root];
  for (auto child : adj[root]) {
    if (!vis[child]) {
      dfs(child, adj, v);
      dp[root] = max(dp[root], dp[child]);
      leaf[root] += leaf[child];
      sum[root] += sum[child];
    }
  }
  long long temp = ceil((double)sum[root] / (double)leaf[root]);
  dp[root] = max(dp[root], temp);
}
void solve() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<vector<long long>> adj(n + 1);
  for (long i = 2; i < n + 1; i++) {
    long long a;
    cin >> a;
    adj[a].push_back(i);
  }
  vector<long long> v(n + 1);
  for (long i = 1; i < n + 1; i++) {
    cin >> v[i];
  }
  memset(vis, false, sizeof(vis));
  memset(sum, 0, sizeof(sum));
  memset(dp, 0, sizeof(dp));
  memset(leaf, 0, sizeof(leaf));
  dfs(1, adj, v);
  cout << dp[1] << endl;
}
int32_t main() { solve(); }
