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

const int N=101;

int n,g[N][N],C[N][N],vis[N],to[N];

char s[N][N];

void dfs(int x)
{
    if(vis[x])
        return;
    vis[x]=1;
    for(int i=1;i<=n;i++)
        if(g[x][i])
            dfs(i);
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            g[i][j]=s[i][j]-'0';
    for(int i=1;i<=n;i++)
    {
        fill(vis+1,vis+n+1,0);
        dfs(i);
        for(int j=1;j<=n;j++)
            to[j]+=vis[j];
    }
    double ans=0;
    for(int i=1;i<=n;i++)
        ans+=1.0/to[i];
    printf("%.10lf\n",ans);
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;

const int MAX = 2e5+10;
int a[MAX];
int b[MAX];
int c[MAX];
vi e[MAX];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
			cin >> a[i];
			b[a[i]] = 1;
	}
	for(int i=0;i<n/2;i++){
			if( a[i] != a[n-i-1] ){
					e[a[i]].push_back(a[n-i-1]);
					e[a[n-i-1]].push_back(a[i]);
			}
	}
	int cnt = 0;
	int v = 0;
	for(int i=1;i<MAX;i++){
			if( b[i] == 0 ) continue;
			v++;
			if( c[i] ) continue;
			cnt ++;
			c[i] = cnt;
			deque <int> D;
			D.push_back(i);
			c[i] = cnt;
			while( !D.empty() ){
					int x = D.front();
					D.pop_front();
					for(int y: e[x]){
							if( c[y] ) continue;
							D.push_back(y);
							c[y] = c[x];
					}
			}
	}
	cout << v - cnt << endl;
}
