#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
const int N=100011;
typedef long double ld;
int a[N],n;
inline signed iut(){
	rr int ans=0; rr char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
inline ld max(ld a,ld b){return a>b?a:b;}
inline ld calc(ld mid){
    rr ld sum=0;
	for (rr int i=1;i<=n;++i)
	    sum+=max(mid*2,a[i]);
	return sum-mid*n;
}
signed main(){
	n=iut();
	for (rr int i=1;i<=n;++i) a[i]=iut();
	rr ld l=0,r=1000000000;
	while (l+1e-8<r){
		rr ld k=(r-l)/3,lmid=l+k,rmid=r-k;
		if (calc(lmid)<calc(rmid)) r=rmid;
		    else l=lmid;
	}
	return !printf("%.8Lf",calc(l)/n);
}
/*
Author : Hocky Yudhiono
11/14/2020 11:34:48 PM

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem, think of it when you're making subtasks
   like when problemsetting.
*/

#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

// If the time limit is strict, try not to use long double

// Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double EPS = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
// Do dir^1 to get reverse direction
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    // Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // cout << fixed << setprecision(10);
}

LL n;
LL cnt[105];
bool isi[105][105];

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            char ch; cin >> ch;
            isi[i][j] = (ch == '1');
        }
    }
    for(int i = 1;i <= n;i++) isi[i][i] = 1;
    for(int k = 1;k <= n;k++){
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                isi[i][j] |= (isi[i][k] && isi[k][j]);
            }
        }
    }
    LD ans = 0;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if(isi[j][i]) cnt[i]++;
        }

        ans += ((LD)(1)/(LD)cnt[i]);
    }
    // for(int i = 1;i <= n;i++) cout << cnt[i] << endl;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}
