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

//A.at(i) = iの約数の個数 = Π(素因数の乗数+1)
//しかし1から10^5まで全て因数分解するのはたぶん間に合わない
//☆違う
//例えば6の約数の個数は4だが、A.at(2) = A.at(3) = 2なのでA.at(6) = 3
//つまり「A.at(n) = A.at(nの約数iのうち、A.at(i)がもっとも大きいもの) + 1
//DP?

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1, 2);
    A.at(1) = 1;
    for (int i = 4; i <= N; i++){
        int root = sqrt(i);
        for (int j = 2; j <= root; j++){
            if(i % j == 0 && A.at(i / j) + 1 > A.at(i)){
                A.at(i) = A.at(i / j) + 1;
            }
        }
    }
    
    for (int i = 1; i <= N; i++){
        cout << A.at(i);
        if(i != N){
            cout << " ";
        }else{
            cout << endl;
        }
    }
}
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 30;
const LL INF = 2e9;

int n, a[MX], ans;

void rec(int i, int xr)
{
    if(i == n)
    {
        ans = min(ans, xr);
        return;
    }

    int vor = 0;

    loop(j,i,n)
    {
        vor |= a[j];
        rec(j+1,vor ^ xr);
    }
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n;
    loop(i,0,n) cin>>a[i];

    ans = INF;
    rec(0,0);

    cout<<ans<<'\n';

    return 0;
}
