#include <bits/stdc++.h>
#define debug(x) cout << #x << ":\t" << (x) << endl;
using namespace std;
#define ll long long
const int N = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
int n;
char s[N];
vector<int>G[N];
int vis[110];
void dfs(int u) {
	vis[u] = 1;
	for (int v : G[u]) {
		if (!vis[v]) {
			dfs(v);
		}
	}
}
double ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		for (int j = 1; j <= n; j++) {
			if (s[j] == '1') {
				G[j].push_back(i);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		dfs(i);
		int t = 0;
		for (int j = 1; j <= n; j++)if (vis[j])t++;
		ans += 1.0 / t;
	}
	printf("%.10lf\n", ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define p push
#define pp pop

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)     //no of 1 in binary
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define clz(n) __builtin_clz(n)       //count leading zeros in binary
#define clzll(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctz(n)      //count trailing zeros

#define B begin()
#define E end()
#define rB rbegin()
#define rE rend()
#define sz size()
#define C count()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define mp make_pair
typedef long long int ll;
#define V(type) vector<type>
#define PQ(type) priority_queue<type>
#define pll pair<ll, ll>
#define F first
#define S second
#define rep(i,n) for(int i=0;i<n;i++)

#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)


#define mod 1000000007
#define INF 9223372036854775807
const double delta = 0.0000000001;
const double pi = 3.1415926535;

ll rand_int(ll l, ll r) 
{ //[l, r]
    #ifdef LOCAL
    static mt19937_64 gen;
    #else
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    #endif
    return uniform_int_distribution<ll>(l, r)(gen);
}

void FAST() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
ll fact(ll n)   //O(N)
{
    if(n<2)return 1;
    else return n*fact(n-1);
}
ll xi(ll x,ll y,ll p){            //gives (x^y)%p             //O(n) atmax  ,not sure though 
    ll r=1;
    x=x%p;
    while(y>0){
        if(y%2==0){
            x*=x;
            x=x%p;
            y/=2;
        }
    else {
        r=((r%p)*(x%p))%p;
        y--;
    }
    
    }
    return r;
}
ll countBits(ll n) {     //log n
    ll count = 0;
    while (n) {
        count++;
        n >>= 1;
    }
    return count;
}

ll isP(ll n) {               //returns 1 if prime          //O(sqrtN)
    if (n == 0 || n == 1) return 0;
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

V(int) decTobin(int n)    //returns a vector binary number,  input a integer
{                               //O(log n)
        V(int) a,ans;
    while(n>0)
    {
        a.pb(n%2);
        n/=2;
    }
    for(int i=a.size()-1;i>=0;i--)
    {
        ans.pb(a[i]);
    }
    return ans;

}
inline ll modadd(ll a, ll b, ll m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}
 
inline ll modmul(ll a, ll b, ll m = mod)
{
    return ((a % m) * (b % m)) % m;
}
void solve()
{
    int n;
    cin>>n;
    n=pow(2,n);
    ll maxa=0,maxb=0,posa=0,posb=0;;
    V(ll) arr(n/2),b(n/2);
    rep(i,n/2){cin>>arr[i];maxa=max(maxa,arr[i]);if(maxa==arr[i])posa=i;}
    rep(i,n/2){cin>>b[i];maxb=max(maxb,b[i]);if(maxb==b[i])posb=i;}
    if(maxa<maxb)cout<<posa+1;
    else cout<<n/2+posb+1;


    return;
}

int main()
{   FAST();
ll ttt;
//cin>>ttt;
ttt=1;
while(ttt--)
{
    solve();
}

return 0;
}