#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "BIGROUP"
#define pll pair<ll, ll>
#define pii pair<pll, ll>
#define fi first
#define se second

using namespace std;
const ll mod = 998244353;
const ll N = 2e5+5;
const int base = 313;
ll n, m, t, k, T, ans, siz, tong, a[N], b[N],  c[N];
string s;

vector<ll> adj[N], kq;


ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
ll pw1(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % (mod-1);
        k = k * k % (mod-1);
    }
    return total;
}
void ask(int i, int j, int l)
{
    cout << i <<" "<< j << " " << l << endl ;
}
void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
    }
    sort(a+1 ,a+1+n);
    for(int i = 1; i <= n; i ++)
    {
        ans = (ans + a[i] * a[i] % mod + a[i] * tong % mod) % mod;
        tong = (tong * 2 + a[i]) % mod;
    }
    cout << ans;
}
int main()
{
    if(fopen(task".INP", "r"))
    {
       freopen(task".INP", "r", stdin);
       freopen(task".OUT", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
5 1

5 7
3 3 7
7 4 8
10 5 4
13 4 3
15 2 8
16 5 2
18 3 7

https://codeforces.com/contest/791/problem/E

*/


#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll d[105][105];
double ans;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < n; j++)
        {
            scanf("%1lld", &d[i][j]);
        }
    }
    for(ll k = 0; k < n; k++)
    {
        for(ll i = 0; i < n; i++)
        {
            for(ll j = 0; j < n; j++)
            {
                d[i][j] |= (d[i][k] & d[k][j]);
            }
        }
    }
    for(ll i = 0; i < n; i++)
    {
        ll cnt = 0;
        for(ll j = 0; j < n; j++)
        {
            if(i == j || d[j][i]) cnt++;
        }
        ans += 1.0 / cnt;
    }
    printf("%.12f", ans);
    return 0;
}
