#include <bits/stdc++.h>

using namespace std;

int N,c,z;
vector<vector<int>> adj(105), tc(105, vector<int>(105));

void dfs(int u, int s) {
    tc[s][u] = true;
    //if (s == 1) cout << u << "\n";
    for (int v: adj[u]) {
    //    if (u == 1) cout << v << " ";
        if (!tc[s][v]) dfs(v,s);
    }
}

int main() {

    cin >> N;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            char c;
            cin >> c;
            if (c=='1') {
                adj[i].push_back(j);
            }
        }
    }

    for (int i = 0; i < N; i++) {
        dfs(i, i);
    }

    double res = 0;

    for (int i = 0; i < N; i++) {
        int c = 0;
        for (int j = 0; j < N; j++) {
            if (tc[j][i]) {
              //  cout << j << " " << i << "\n";
                c++;
            }
        }
        res += 1.0/c;;
    }

    cout << setprecision(15) << res << "\n";

    return 0;
}
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,n) repi(i,0,n)
#define repi(i,a,n) for(ll i = a;i < (ll)n;++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SHOW(str,val) cout<<(str)<<" : "<<(val)<<endl;

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
// using P = pair<int, int>;
void YN(bool a) { cout << (a ? "Yes" : "No"); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}

// 最大公約数 : 3,4 ->  1
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve()
{
  ll n, a;
  cin >> n;
  ll ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> a;
    ans = gcd(ans, a);
  }

  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}