#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  unordered_map<ll,ll> mp;
  rep(i,n) {
    for(ll x = 1; x*x <= a[i]; x++) {
      if(a[i] % x == 0) {
        mp[x] = (mp[x] ? gcd(mp[x],a[i]) : a[i]);
        mp[a[i]/x] = (mp[a[i]/x] ? gcd(mp[a[i]/x],a[i]) : a[i]);
      }
    }
  }
  int ans = 0;
  for(auto x : mp) if(x.first == x.second and x.first <= a[0]) ans++;
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Sort(a) sort(a.begin(),s.end())

int main(){
    int n;
    int m=5;
    
    cin >> n;
    vector<vector<int>> s(n,vector<int>(m));

    
    rep(i,n)rep(j,m) cin >> s[i][j];

    int l=0; int r=1001001001;
    while(l+1<r){
        int mid = (l+r)/2;
        int x;
        vector<int> b;
        rep(i,n){
            x=0;
            rep(j,m){
                if(s[i][j]>=mid){
                    x|=1<<j;
                }
            }
        b.push_back(x);
        }
        sort(b.begin(),b.end());
        b.erase(unique(b.begin(),b.end()),b.end());
        bool ok=false;
        rep(i,b.size())rep(j,i+1)rep(k,j+1){
            if((b[i]|b[j]|b[k])==(1<<m)-1){
                ok=true;
            }
        }
        if(ok){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    cout << l << endl;
    return 0;
}