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

#define ll                     long long int
#define ld                     long double
#define ff                     first
#define ss                     second
#define pb                     push_back
#define pii                    pair <ll , ll>
#define vi                     vector <ll>
#define vii                    vector <pair <ll , ll>>
#define mii                    map <ll , ll>
#define mci                    map <char , ll>
#define mcc                    map <char , char>
#define pqb                    priority_queue <ll>
#define pqs                    priority_queue <ll , vi,greater<ll> >
#define setbits(x)             __builtin_popcountll(x)
#define zerobits(x)            __builtin_ctzll(x)
#define inf                    (ll) (9e18)
#define sp(x , y)              fixed << setprecision(y) << x
#define mk(arr , n , type)     type *arr = new type[n];
#define mar(arr , n , type)    type arr[n];
#define w(x)                   ll x; cin >> x; while(x--)
#define rep(i , j , n)         for(ll i = j ; i < n ; i++)
#define f(n)                   for(ll i = 0 ; i < n ; i++)
#define all(p)                 p.begin() , p.end()
#define ub(a , b)              upper_bound(all(a) , b)
#define lb(a , b)              lower_bound(all(a) , b)
#define in(arr , n)            for(ll i = 0 ; i < n ; i++) cin >> arr[i];
#define out(arr , n)           for(ll i = 0 ; i < n ; i++) cout << arr[i] << " "; cout << endl;
#define d(x)                   cerr << #x << " = " << x << endl;
#define len(x)                 x.length();
#define fast_io                ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
    ll n;
    cin >> n;

    mar(arr , n , ll);
    in(arr , n);


    ll ans = 0 , cnt = 0 , index = -1;
    for(ll i = 2 ; i <= 1000 ; i++) {
        cnt = 0;
        for(ll j = 0 ; j < n ; j++) {
            if(arr[j] % i == 0) {
                cnt ++;
            }
        }
        if(cnt >= ans) {
            ans = max(ans , cnt);
            index = i;
        }
    }

    cout << index << endl;
    return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	vector<vector<int64>> aa(nn + 1, vector<int64>(1ll << nn, 0ll));
	for(int64 ii = 0;ii < (1ll << nn);ii++)
	{
		cin >> aa[0][ii];
	}
	for(int64 ii = 0;ii < nn;ii++)
	{
		for(int64 jj = 0;jj < 1ll << nn;jj += (2ll << ii))
		{
			int64 tmp = max(aa[ii][jj], aa[ii][jj + (1ll << ii)]);
			aa[ii + 1][jj] = tmp;
		}
		//cout << aa[ii + 1][0] << ' ';
		for(int64 jj = 1;jj < 1ll << nn;jj++)
		{
			if(aa[ii + 1][jj] == 0)
			{
				aa[ii + 1][jj] = aa[ii + 1][jj - 1];
			}
			//cout << aa[ii + 1][jj] << ' ';
		}
		//cout << endl;
	}
	int64 memo = aa[nn][0];
	if(aa[nn - 1][0] != memo)
	{
		memo = aa[nn - 1][0];
	}
	else
	{
		memo = aa[nn - 1][(1ll << nn) - 1];
	}
	for(int64 ii = 0;ii < 1ll << nn;ii++)
	{
		if(aa[0][ii] == memo)
		{
			cout << ii + 1 << endl;
			return 0;
		}
	}
	return 0;
}