#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159265359;
const long long N = 2e5 + 9;
long long a[N], dp[N];
pair<long long, long long> arr[N];
vector<long long> v[N];
long long sum(long long ver, long long par) {
  if (v[ver].size() == 1 && ver != 1) {
    dp[ver] = 1;
    return 1;
  }
  for (auto it : v[ver]) {
    if (it == par) continue;
    dp[ver] += sum(it, ver);
  }
  return dp[ver];
}
void dfs(long long ver, long long par) {
  if (v[ver].size() == 1 && ver != 1) {
    arr[ver] = {a[ver], 0};
    return;
  }
  long long val = a[ver], buf = 0, mx = 0;
  for (auto it : v[ver]) {
    if (it == par) continue;
    dfs(it, ver);
    buf += arr[it].second;
    mx = max(mx, arr[it].first);
  }
  for (auto it : v[ver]) {
    if (it == par) continue;
    buf += (mx - arr[it].first) * dp[it];
  }
  if (buf >= val) {
    arr[ver] = {mx, buf - val};
    return;
  }
  val -= buf;
  long long tmp = val / dp[ver] + (val % dp[ver] != 0);
  arr[ver] = {mx + tmp, tmp * dp[ver] - val};
  return;
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = (long long)(2); i <= (long long)(n); i++) {
    long long x;
    cin >> x;
    v[x].push_back(i);
    v[i].push_back(x);
  }
  for (long long i = (long long)(1); i <= (long long)(n); i++) cin >> a[i];
  sum(1, 0);
  dfs(1, 0);
  cout << arr[1].first << "\n";
}
