#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int gr[101][101];
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < N; j ++) {
      char c;
      cin >> c;
      gr[i][j] = (c == '1');
    }
  }
  for (int i = 0; i < N; i ++) gr[i][i] = 1;
  for (int p = 0; p < 10; p ++) {
    int gr_[101][101];
    for (int i = 0; i < N; i ++) {
      for (int j = 0; j < N; j ++) {
        int kj = 0;
        for (int k = 0; k < N; k ++) {
          kj += gr[i][k] * gr[k][j];
        }
        gr_[i][j] = (kj > 0);
      }
    }
    for (int i = 0; i < N; i ++) {
      for (int j = 0; j < N; j ++) {
        gr[i][j] = gr_[i][j];
        //cout << gr[i][j];
      }
      //cout << endl;
    }
    //cout << endl;
  }
  double ans = 0;
  for (int i = 0; i < N; i ++) {
    double kj = 0;
    for (int j = 0; j < N; j ++) {
      kj += (double)gr[j][i];
    }
    ans += 1 / kj;
  }
  cout << setprecision(15) << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;

const int maxn=100000;
int f[maxn+5],l[maxn+5];
bool d[maxn+5];
vector<int>g[maxn+5];
bool cmp(int i,int j)
{
    return (f[i]-l[i])>(f[j]-l[j]);
}
void dfs(int x)
{
    //cout<<x<<endl;
    if(g[x].size()==0)
    {
        l[x]=1;
        f[x]=0;
        d[x]=1;
        return;
    }
    vector<int>v;
    d[x]=0;
    f[x]=0;
    l[x]=1;
    int tmp1=0,tmp2=0;
    for(int i=0; i<g[x].size(); i++)
    {
        int id=g[x][i];
        dfs(id);
        d[x]^=d[id];
        if(d[id])
            v.push_back(id);
        else
        {
            if(f[id]>=l[id])
            {
                f[x]+=f[id];
                l[x]+=l[id];
            }
            else
            {
                tmp1+=f[id];
                tmp2+=l[id];
            }
        }
    }
    sort(v.begin(),v.end(),cmp);
    for(int i=0; i<v.size(); i++)
    {
        int id=v[i];
        if(i%2==0)
        {
            l[x]+=l[id];
            f[x]+=f[id];
        }
        else
        {
            f[x]+=l[id];
            l[x]+=f[id];
        }
    }
    //cout<<f[x]<<" "<<l[x]<<endl;
    if(d[x])
    {
        f[x]+=tmp2;
        l[x]+=tmp1;
    }
    else
    {
        f[x]+=tmp1;
        l[x]+=tmp2;
    }
    d[x]^=1;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=2; i<=n; i++)
    {
        int x;
        scanf("%d",&x);
        g[x].push_back(i);
    }
    dfs(1);
    //for(int i=1;i<=n;i++)
    //cout<<d[i]<<" "<<l[i]<<" "<<f[i]<<endl;
    printf("%d\n",l[1]);
}
