/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pi                                acos( -1.0 )
#define rep( i, a, n )                    for ( ll i = a; i < n; i++ )
#define per( i, a, n )                    for ( ll i = n - 1; i >= a; i-- )
#define ll                                long long
#define all( x )                          ( x ).begin(), ( x ).end()

typedef tree < ll, null_type, less < ll >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ll N = 2e5 + 9;
const ll MOD = 1e9 + 7;




ll sum( string x )
{
      return ( x[ 0 ] - '0' ) + ( x[ 1 ] - '0' ) + ( x[ 2 ] - '0' );
}

void solve( int t )
{
      string A, B;
      cin >> A >> B;

      cout << max( sum( A ), sum( B ) );
}

int main()
{
      ios_base::sync_with_stdio( false );
      cin.tie( NULL );
      cout.tie( NULL );
      cout << setprecision( 12 );

      int t = 1;
      //cin >> t;

      for ( int i = 1; i <= t; ++i )  solve( i );


      return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  int m=a[n-1];
  vector<int> d(m+1);
  rep(i,n){
    rep2(j,2,a[i]+1){
if(a[i]%j==0) d[j]++;
    }
  }
  ll max=0;
  rep(i,m+1){
   if(d[i]>max) max=d[i];
  }
 rep(i,m+1){
   if(d[i]==max){
     cout<<i;
     return 0;
   }
 }
return 0;
}