#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long inf = 1e18, N = 200005;
long long n, mx, a[N];
vector<long long> g[N];
long long dfs(long long node) {
  if (!(long long)g[node].size()) {
    if (mx >= a[node]) return mx - a[node];
    return -1;
  }
  long long sum = 0;
  for (auto it : g[node]) {
    long long temp = dfs(it);
    if (temp < 0) {
      sum = -1;
      break;
    }
    sum = (sum + temp) % inf;
  }
  if (sum >= a[node]) return (sum - a[node]);
  return -1;
}
bool check(long long x) {
  mx = x;
  if (dfs(1) >= 0) return true;
  return false;
}
void solve() {
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long x;
    cin >> x;
    g[x].push_back(i);
  }
  long long tot = 0;
  for (long long i = 1; i <= n; i++) cin >> a[i], tot += a[i];
  long long lo = 0, hi = tot;
  while (lo < hi) {
    long long mid = (lo + (hi - lo) / 2);
    if (check(mid))
      hi = mid;
    else
      lo = (mid + 1);
  }
  cout << lo << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
