#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(vector<T> &v) {
  for (int i = 0; i < (int)v.size(); ++i) cout << v[i] << " ";
  cout << endl;
}
int nxt() {
  int x;
  cin >> x;
  return x;
}
long long nxtl() {
  long long x;
  cin >> x;
  return x;
}
string nxts() {
  string x;
  cin >> x;
  return x;
}
double nxtd() {
  double x;
  cin >> x;
  return x;
}
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long power_mod(long long a, long long b, long long mo) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans % mo * a % mo) % mo;
    }
    a = (a % mo * a % mo) % mo;
    b /= 2;
  }
  return ans;
}
long long POW(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a;
    }
    a = a * a;
    b /= 2;
  }
  return ans;
}
string int_to_string(long long x) {
  stringstream ss;
  ss << x;
  string ni = ss.str();
  return ni;
}
long long string_to_int(string x) {
  long long n;
  stringstream s(x);
  s >> n;
  return n;
}
void INVERSE(vector<long long> &fact, vector<long long> &mul, int n, int mod) {
  fact[0] = 1;
  for (long long i = 1; i <= n; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  vector<long long> inv(n + 1);
  inv[0] = 1;
  inv[1] = 1;
  for (long long i = 2; i <= n; ++i) {
    inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
  }
  mul[0] = 1;
  for (int i = 1; i <= n; ++i) {
    mul[i] = (mul[i - 1] * inv[i]) % mod;
  }
}
int n;
vector<vector<int>> v(2e5 + 1);
long long value[200000 + 1];
long long dp[200000 + 1];
long long sum[200000 + 1];
long long leaf[200000 + 1];
void dfs(int val = 0, int parent = -1) {
  if ((int)v[val].size() == 0) {
    dp[val] = sum[val] = value[val];
    leaf[val] = 1;
    return;
  }
  sum[val] = value[val];
  for (auto x : v[val]) {
    if (x == parent) continue;
    dfs(x, val);
    sum[val] += sum[x];
    leaf[val] += leaf[x];
    dp[val] = max(dp[val], dp[x]);
  }
  dp[val] = max(dp[val], (sum[val] + leaf[val] - 1) / leaf[val]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    x--;
    v[x].push_back(i);
  }
  for (int i = 0; i < n; ++i) cin >> value[i];
  dfs();
  cout << dp[0];
}
