#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;

void solve() {

}

int main() {
  // input
  int N;
  cin >> N;
  vector<int> A(N, 0);
  rep(i, N) cin >> A[i];

  sort(A.begin(), A.end());

  int k = 0;
  int ans = 0;
  for (int i = 2; i <= A[N - 1]; i++)
  {
    int gcd = 0;
    for (int a : A)
    {
      if (a % i == 0) {
        gcd++;
      }
    }
    if (k <= gcd) {
      k = gcd;
      ans = i;
    }
  }

  cout << ans << endl;
}
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod(ll a);

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> a(200000,0);
  for(int i=0;i<n;++i) cin >> p[i];
  int min=0;
  for(int i=0;i<n;++i){
    a[p[i]]++;
    //cout<<"input "<<p[i]<<" "<<min<<endl;
    if(min==p[i]){
      int k=p[i];
      while(a[k]!=0) k++;
      min = k;
    }
    cout<<min<<endl;
  }
  
    
}

ll mod(ll a){
  int b=1000000007;
  while(a<0) a+=b;
  return a%b;
}