#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct d{ll f, s, t;};//first, second, turn

bool comp(d a, d b) {
  if (a.t == 0 || b.t == 0) {
    return a.t >= b.t;
  }
  return (a.s - a.f) >= (b.s - b.f);
}

ll N;
vector<ll> p;
vector<vector<ll>> child;
d dfs(ll now, ll turn) {
  vector<ll> FS(2, 0);
  FS.at(0) += 1;
  turn = (turn + 1) % 2;
  vector<d> ds;
  vector<vector<ll>> datas;
  for (ll i = 0; i < child.at(now).size(); ++i) {
    d temp = {1, 0, 1};
    if (child.at(child.at(now).at(i)).size() != 0) {
      temp = dfs(child.at(now).at(i), 0);
    }
    if (temp.f <= temp.s && temp.t == 0) {
      FS.at(turn) += temp.s;
      FS.at((turn + 1) % 2) += temp.f;
    }
    else {
      ds.push_back(temp);
      datas.push_back({temp.t, temp.s - temp.f, temp.f, temp.s, temp.t});
    }
  }
  // for (ll i = 0; i < datas.size(); ++i) {
  //   cout << datas.at(i).at(0) << ' ' << datas.at(i).at(1) << "\n";
  // }
  sort(rrng(datas));
  // for (ll i = 0; i < datas.size(); ++i) {
  //   cout << datas.at(i).at(0) << ' ' << datas.at(i).at(1) << "\n";
  // }
  // cout << "\n";
  for (ll i = 0; i < datas.size(); ++i) {
    d temp = {datas.at(i).at(2), datas.at(i).at(3), datas.at(i).at(4)};
    FS.at(turn) += temp.s;
    FS.at((turn + 1) % 2) += temp.f;
    turn = (turn + temp.t) % 2;
  }
  // cout << "now" << now + 1 << "\n";
  // cout << FS.at(0) << ' ' << FS.at(1) << ' ' << turn << "\n";
  return {FS.at(0), FS.at(1), turn};
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;
  p = vector<ll>(N, -1);
  child = vector<vector<ll>>(N);
  for (ll i = 1; i < N; ++i) {
    cin >> p.at(i);
    p.at(i) -= 1;
    child.at(p.at(i)).push_back(i);
  }
  cout << dfs(0, 0).f << "\n";
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

double eval(double x,const vector<int> &a){
    double ret=0;
    for(int amt:a){
        double d=amt;
        ret+=x+d-min(d,x*2);
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int &x:a)
        cin>>x;
    double l=0,r=1000000000;
    while(r-l>1e-7){
        double m1=(l*2+r)/3,m2=(l+r*2)/3;
        if(eval(m1,a)<eval(m2,a))
            r=m2;
        else
            l=m1;
    }
    cout<<setprecision(15)<<eval((l+r)/2,a)/n<<endl;
}