#include <bits/stdc++.h>

#define debug(var)  do{std::cout << #var << " :";std::cout << std::endl;view(var);}while(0)
template<typename T> void view(T e){ std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){ int c = v.size(); std::cout << "{"; for(const auto& e : v){ std::cout << e; if (--c) std::cout << ", "; } std::cout << "}" << std::endl; }
template<typename T, typename U> void view(const std::pair<T, U>& v){ std::cout << v.first << ", " << v.second << std::endl; }
template<typename T> void view(const std::set<T>& v){ int c = v.size(); std::cout << "{"; for(const auto& e : v){ std::cout << e; if (--c) std::cout << ", "; } std::cout << "}" << std::endl; }
template<typename T, typename U> void view(const std::map<T, U>& v){ std::cout << "{" << std::endl; for(const std::pair<T, U>& e : v){ std::cout << e.first << ", " << e.second << std::endl; } std::cout << "}" << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cout << "{" << std::endl; for(const auto& v : vv){ view(v); } std::cout << "}" << std::endl; }

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int n; cin >> n;
    vector<int> A(n);
    rep(i,n) {
        cin >> A[i];
    }

    int cnt = 0;
    int ans = -1;
    for (int i = 2; i <= 1000; i++) {
        int tmp = 0;
        for (auto x : A) {
            if (x % i == 0) tmp++;
        }

        if (chmax(cnt, tmp)) ans = i;
    }

    cout << ans << endl;
}
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

struct person {
    ll id;
    ll a;
    ll b;
};

bool recursive(ll N, ll start, ll donenum, ll anymovenum, vector<ll>& start_static, vector<ll>& end_static, ll skip_kai, ll rest_add, ll rest_end, vector<bool>& checked) {
    if (anymovenum < 0) {
        return false;
    }
    if (donenum == N) {
        return true;
    }
    if (start >= 2 * N) {
        return false;
    }

    if (start <= rest_end) {
        ll end = start + rest_add;
        if ((start_static[end] >= 0) ||
            (end_static[start] >= 0) ||
            (start_static[start] >= 0 && end_static[end] >= 0 && start_static[start] != end_static[end])) {
            return false;
        }
        ll anym = (start_static[start] >= 0 || end_static[end] >= 0) ? anymovenum : anymovenum - 1;
        return recursive(N, start + 1, donenum + 1, anym, start_static, end_static, skip_kai, rest_add, rest_end, checked);
    } else if (skip_kai) {
        return recursive(N, skip_kai, donenum, anymovenum, start_static, end_static, 0, -1, -1, checked);
    } else {
        if (checked[start]) {
            return false;
        }
        checked[start] = true;
        for (ll end = start + 1; true; end++) {
            if (end - 1 + end - start > 2 * N || end > start + N) {
                break;
            }
            if ((start_static[end] >= 0) ||
                (end_static[start] >= 0) ||
                (start_static[start] >= 0 && end_static[end] >= 0 && start_static[start] != end_static[end])) {
                continue;
            }
            ll anym = (start_static[start] >= 0 || end_static[end] >= 0) ? anymovenum : anymovenum - 1;
            bool ok = recursive(N, start + 1, donenum + 1, anym, start_static, end_static, end + end - start, (end - start), end - 1, checked);
            if (ok) {
                return true;
            }
        }
        return false;
    }
}

bool solve(ll N, vector<person>& persons) {
    set<ll> duplicate;
    for (auto p : persons) {
        if (p.a >= 0) {
            if (duplicate.count(p.a)) {
                return false;
            }
            duplicate.insert(p.a);
        }
        if (p.b >= 0) {
            if (duplicate.count(p.b)) {
                return false;
            }
            duplicate.insert(p.b);
        }
    }
    vector<ll> start_static(2 * N + 1, -1);
    vector<ll> end_static(2 * N + 1, -1);
    for (auto p : persons) {
        if (p.a >= 0) {
            start_static[p.a] = p.id;
        }
        if (p.b >= 0) {
            end_static[p.b] = p.id;
        }
    }
    ll anymovenum = 0;
    for (auto p : persons) {
        if (p.a == -1 && p.b == -1) {
            anymovenum++;
        }
    }
    vector<bool> checked(2 * N + 1, false);
    return recursive(N, 1, 0, anymovenum, start_static, end_static, 0, -1, -1, checked);
}

int main() {
    ll N;
    cin >> N;

    vector<person> persons(N);
    for (ll i = 0; i < N; i++) {
        person p;
        cin >> p.a >> p.b;
        p.id = i;
        persons[i] = p;
    }
    if (solve(N, persons)) {
        print("Yes");
    } else {
        print("No");
    }
}
