#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int t, n, x, leafNum[N];
long long a[N], ans;
vector<int> g[N];
void dfs(int root) {
  leafNum[root] = (g[root].size() == 0);
  for (int i = 0; i < g[root].size(); i++) {
    int y = g[root][i];
    dfs(y);
    a[root] += a[y];
    leafNum[root] += leafNum[y];
  }
  ans = max(ans, a[root] / leafNum[root] + (a[root] % leafNum[root] != 0));
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  ans = 0;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    g[x].push_back(i);
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  dfs(1);
  cout << ans << endl;
}
