#include <bits/stdc++.h>
using namespace std;
struct node {
  long long leaf, citizen, curAns;
  bool extraOne;
};
vector<long long> v[200005];
long long arr[200005];
bool vis[200005];
node dfs(long long u) {
  long long i, l = 0, c = arr[u];
  node retd, bestRetd;
  bestRetd.curAns = 0;
  bestRetd.extraOne = false;
  for (i = 0; i < v[u].size(); i++) {
    if (vis[v[u][i]]) continue;
    vis[v[u][i]] = true;
    retd = dfs(v[u][i]);
    if (retd.curAns + (long long)retd.extraOne >
        bestRetd.curAns + (long long)bestRetd.extraOne) {
      bestRetd = retd;
    }
    l += retd.leaf;
    c += retd.citizen;
  }
  node myNode;
  myNode.citizen = c;
  myNode.leaf = l;
  if (u != 1 && (long long)v[u].size() == 1) {
    myNode.leaf = 1;
    l = 1;
    myNode.curAns = c / l;
    myNode.extraOne = (bool)(c % l);
  } else if (c / l + (long long)((bool)(c % l)) >
             bestRetd.curAns + (long long)bestRetd.extraOne) {
    myNode.curAns = c / l;
    myNode.extraOne = (bool)(c % l);
  } else {
    myNode.curAns = bestRetd.curAns;
    myNode.extraOne = bestRetd.extraOne;
  }
  return myNode;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, i, x;
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> x;
    v[i].push_back(x);
    v[x].push_back(i);
  }
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= n; i++) cin >> arr[i];
  vis[1] = true;
  node Ans;
  Ans = dfs(1);
  cout << Ans.curAns + (long long)Ans.extraOne << "\n";
  return 0;
}
