// #include<atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1LL<<60;
const int INF = 1LL<<17;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};
// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

int main(){
    ll n;   cin >> n;
    set<ll> st;
    rep(i, n){
        ll x;   cin >> x;
        st.insert(x);
    }
    while(1<st.size()){
        ll p = *st.rbegin();
        st.erase(p);
        ll nv = p%*st.begin();
        if(nv==0) continue;
        st.insert(nv);
    }
    cout << *st.begin() << endl;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int all_counter = 0, counter = 0;

vector<bool> gone;
void dfs2(const Graph &G, int v) {

    // if(all_of(gone.begin(), gone.end(), [](int x) { return x == 1; })){
    //     cout <<  "どうでしょう" << v << endl;
    //     all_counter++;
    //     // gone.assign(N, false);
    //     return;
    // }
    

    if(gone[v] == 0){
        counter++;
    }
    gone[v] = true;


    

    for (auto next_v : G[v]) { 
        gone[next_v] = true;
    }


     if(all_of(gone.begin(), gone.end(), [](int x) { return x == 1; })){
                all_counter++;
                return;
    }
    

    rep(i, N){
        if(gone[i] == 0){ 
            // cout << "さいき "  << i << endl;
            dfs2(G, i);
        }
    }

  
    // if(all_of(gone.begin(), gone.end(), [](int x) { return x == 1; })){
    //     return;
    // }  

}

int main() {
    // 頂点数と辺数
    cin >> N;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        rep(j, N){
            if(s[j] == '1') G[i].push_back(j);
        }
    }

    Graph G2(N);

    // 頂点 0 をスタートとした探索
    seen.assign(N, false); // 全頂点を「未訪問」に初期化
    rep(i, N){
        dfs(G, i);
        rep(j, N){
            if(seen[j]) G2[i].push_back(j);
        }
        seen.assign(N, false);
    }

    
    double res = 0.0;
    for (int i = 0; i < N; ++i) {
        int num = 0;
        for (int j = 0; j < N; ++j){
            for(int k = 0;k < G2[j].size();k++){
                if(G2[j][k] == i){ 
                    num++;
                   
                    break;
                }
                else if(j == i){
                    num++;
                    
                    break;
                }
            }
        }
        res += 1.0 / num;
    }

    printf("%.15f\n", res);
    // gone.assign(N, false);
    // rep(i, N){
    //     dfs2(G2, i);
    //     gone.assign(N, false);
    // }

    // // cout << counter << endl;
    // // cout << all_counter << endl;
    
    // long double ans = (long double)counter/all_counter;

    // printf("%.15Lf\n", ans);
}