/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

template<typename T> T gcd(T x, T y) {
  while (y > 0){
    T tmp = x % y;
    x = y;
    y = tmp;
  }
  return x;
}

class SegmentTree {
 public:
  SegmentTree(const std::vector<int>& vec, const int& initial_value,
              std::function<int(int, int)> operation)
        : initial_value_(initial_value),
          vec_(vec),
          operation_(operation) {}
  void Initialize();
  void Update(int position, int new_value);
  int Query(int a, int b, int k, int l, int r);

 private:
  int n_;
  const int initial_value_;
  const std::vector<int> vec_;
  std::vector<int> data_;
  std::function<int(int, int)> operation_;
};

void SegmentTree::Initialize() {
  int vsize = static_cast<int>(vec_.size());
  n_ = 1;
  while (n_ < vsize) {
    n_ <<= 1;
  }
  data_.assign(2 * n_ - 1, initial_value_);
  for (int i = 0; i < vsize; ++i) {
    data_[i + n_ - 1] = vec_[i];
  }
  for (int i = n_ - 2; i >= 0; --i) {
    data_[i] = operation_(data_[2 * i + 1], data_[2 * i + 2]);
  }
}

void SegmentTree::Update(int position, int new_value) {
  position += n_ - 1;
  data_[position] = new_value;
  while (position > 0){
    position = (position - 1) / 2;
    data_[position] = operation_(data_[2 * position + 1], data_[2 * position + 2]);
  }
}

int SegmentTree::Query(int a, int b, int k = 0, int l = 0, int r = -1) {
  if (r < 0) r = n_;
  if (r <= a || b <= l) return initial_value_;
  if (a <= l && r <= b) return data_[k];
  int vl = Query(a, b, 2 * k + 1, l, (l + r) / 2);
  int vr = Query(a, b, 2 * k + 2, (l + r) / 2, r);
  return operation_(vl, vr);
}

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];

  auto f = [](int a, int b){return gcd(a, b);};

  SegmentTree seg(v, 0, f);
  seg.Initialize();

  int ans = max(seg.Query(1, n), seg.Query(0, n - 1));

  for (int i = 1; i <= n - 2; ++i) {
    chmax(ans, f(seg.Query(0, i), seg.Query(i + 1, n)));
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 2048