#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> adj;
vector<long long> a;
pair<pair<long long, long long>, int> dfs(int x) {
  if (adj[x].empty()) {
    return {{a[x], 0}, 1};
  }
  pair<pair<long long, long long>, int> result;
  for (auto y : adj[x]) {
    auto p = dfs(y);
    if (p.first.first > result.first.first) {
      swap(p, result);
    }
    result.first.second += p.first.second;
    result.first.second += (result.first.first - p.first.first) * p.second;
    result.second += p.second;
  }
  long long fill_cnt = min(result.first.second, a[x]);
  long long rem_cnt = a[x] - fill_cnt;
  result.first.second -= fill_cnt;
  result.first.first +=
      (rem_cnt / result.second) + (rem_cnt % result.second > 0);
  if (rem_cnt % result.second > 0) {
    result.first.second = result.second - (rem_cnt % result.second);
  }
  return result;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  adj.resize(n);
  a.resize(n);
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    adj[--x].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  auto p = dfs(0);
  cout << p.first.first << endl;
  return 0;
}
