#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, ans, a[N];
vector<vector<long long> > G(N);
pair<long long, pair<long long, long long> > dfs(long long node) {
  pair<long long, pair<long long, long long> > p;
  p.first = 0, p.second.first = a[node], p.second.second = 0;
  for (auto i : G[node]) {
    pair<long long, pair<long long, long long> > c = dfs(i);
    p.first = max(p.first, c.first);
    p.second.first += c.second.first;
    p.second.second += c.second.second;
  }
  p.second.second = max(1LL, p.second.second);
  long long temp =
      p.second.first / p.second.second + (p.second.first % p.second.second > 0);
  p.first = max(p.first, temp);
  return p;
}
void Test() {
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long x;
    cin >> x;
    G[x].push_back(i);
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  pair<long long, pair<long long, long long> > ans = dfs(1);
  cout << ans.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(10);
  Test();
  return 0;
}
