#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, l, n) for (int i = (l); i < (int)(n); i++)
using ll = long long;
int main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        a[i] %= 200;

    }
    vector<int> cnt(200);
    rep(i,n) cnt[a[i]]++;
    
    ll ans=0;
    rep(i,200){
        ans += (ll)(cnt[i]*(ll)(cnt[i]-1))/2;
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

vector<int> adj[101];
bool vis[101][101];
int cnt;

void dfs(int v, int stem){
	vis[stem][v]=1;
	cnt++;
	for(auto u:adj[v]){
		if(!vis[stem][u]) dfs(u,stem);
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	for(int i=1; i<=n; i++){
		string s;
		cin>>s;
		for(int j=0; j<n; j++){
			if(s[j]=='1') adj[j+1].push_back(i);
		}
	}

	cout << setprecision(11);

	double ans = 0;

	for(int v=1; v<=n; v++){
		cnt = 0;
		dfs(v,v);
		ans += (double)1 / (double)cnt;
	}

	cout << ans << "\n";
}