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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll LINF = 1e18;

// 3人選ぶ
// 3最大値で圧縮 => 5つの内の最小値を最大化
// ある1個の値に着目した時、その値が最終値に成り得るか
// 2数の和を求める
// ｘが作れるか ＝＞ 
// 最大値をとって最小値をとる
// 2組を決める
// もう1人は、5つのパラメータそれぞれについてソートしておけば
// 最小値について降順にソートしておく idxももつ
// 2組を決めた時、5つのうちどれを最小値とするか

int n;
vc<vc<int>> a;

bool isOk(ll mid){
  vc<int> used(1<<5), X;
  rep(i,n){
    int x=0;
    rep(j,5){
      if(a[i][j]>=mid) x+=(1<<j);
    }
    if(!used[x]){
      used[x]=1;
      X.push_back(x);
    }
  }
  // cout<<X.size()<<endl;
  int all=(1<<5)-1;
  rep(i,X.size()){
    int x=X[i];
    if(x==all) return 1;
    irep(j,i+1,X.size()){
      int y=x|X[j];
      if(y==all) return 1;
      irep(k,j+1,X.size()){
        int z=y|X[k];
        if(all==z) return 1;
      }
    }
  }
  return 0;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>n;
  a = vc<vc<int>>(n,vc<int>(5));
  rep(i,n) rep(j,5) cin>>a[i][j];
  
  ll ng=1e9+1, ok=1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    // cout<<ok<<' '<<ng<<' '<<mid<<endl;
    if(isOk(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}
#include <bits/stdc++.h>

using namespace std;

const int N = 2e3 + 5;

int n, a[N];
inline int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }

set <int> s;
set <int> :: iterator it;
inline void divide(int num)
{
	for (int i = 1; i <= sqrt(num); i++)
	if (num % i == 0) {
		s.insert(i);
		s.insert(num / i);
	}
} 

int main()
{
	scanf ("%d", &n);
	int minv = 0x3f3f3f3f;
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
		minv = min(minv, a[i]);
		divide(a[i]);
	}
	
	int ans = 1;
	for (it = s.begin(); it != s.end(); it++)
	{
		int num = (*it);
		if (num >= minv) break;
		
		int val = 0;
		for (int i = 1; i <= n; i++)
		if (a[i] % num == 0) val = gcd(val, a[i]);
		
		if (val == num) ans++;
	}
	printf ("%d\n", ans);
  	return 0;
}