#include <bits/stdc++.h>
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
using namespace std;
void solve();
mt19937 rnd(2007);
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    swap(rng, rnd);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
}




void solve() {
    int n; cin >> n;
    vector<int> a(n); forn (i, n) cin >> a[i];
    int mn = *min_element(all(a));
    unordered_map<int, int> vals;
    for (auto v : a){
        for (int i = 1; i * i <= v; ++i){
            if (v % i == 0){
                vals[i] = __gcd(vals[i], v / i);
                vals[v / i] = __gcd(vals[v / i], i);
            }
        }
    }
    int ans = 0;
    for (auto i : vals){
        if (i.first <= mn && i.second == 1) {
            ++ans;
        }
    }
    cout << ans << endl;
}
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, 0, N) {
        cin >> A[i] >> B[i];
    }
    P undefined_val = P(-1, -1);
    int left_dir = 0;
    int right_dir = 1;
    vector<P> dir_and_idx(2 * N + 1, undefined_val);
    rep(i, 0, N) {
        if (A[i] > 0 && B[i] > 0 && A[i] >= B[i]) {
            cout << "No" << endl;
            return 0;
        }
        if (A[i] > 0 && dir_and_idx[A[i]] != undefined_val) {
            cout << "No" << endl;
            return 0;
        }
        if (A[i] > 0) {
            dir_and_idx[A[i]] = P(i, left_dir);
        }
        if (B[i] > 0 && dir_and_idx[B[i]] != undefined_val) {
            cout << "No" << endl;
            return 0;
        }
        if (B[i] > 0) {
            dir_and_idx[B[i]] = P(i, right_dir);
        }
    }
    vector<bool> dp(2 * N + 1, false);
    dp[0] = true;
    rep(i, 1, 2 * N + 1) {
        if (dir_and_idx[i].second == left_dir) {
            continue;
        }
        rep(j, 0, i - 1) {
            if ((i - j) % 2) {
                continue;
            }
            bool is_ok = true;
            rep(k, j + 1, j + (i - j) / 2 + 1) {
                if (dir_and_idx[k].second == right_dir || dir_and_idx[k + (i - j) / 2].second == left_dir) {
                    is_ok = false;
                    break;
                }
                int left_idx = dir_and_idx[k].first;
                int right_idx = dir_and_idx[k + (i - j) / 2].first;
                if (left_idx >= 0 && right_idx >= 0 && left_idx != right_idx) {
                    is_ok = false;
                    break;
                }
                if (left_idx >= 0 && A[left_idx] > 0 && B[left_idx] > 0 && left_idx != right_idx) {
                    is_ok = false;
                    break;
                }
                if (right_idx >= 0 && A[right_idx] > 0 && B[right_idx] > 0 && left_idx != right_idx) {
                    is_ok = false;
                    break;
                }
            }
            dp[i] = (dp[i] | (dp[j] & is_ok));
        }
    }
    if (dp[2 * N]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}