#pragma GCC optimize "O3" #pragma GCC target "avx" #include #include #include #include #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) using ll = long long; using namespace std; // ll gcd(ll a, ll b) { while (a) { b %= a; swap(a, b); } return b; } struct rational_t { ll p, q; // q may be 0 bool operator == (rational_t other) const { return this->p * other.q == this->q * other.p; } rational_t operator + (rational_t other) const { return { this->p * other.q + other.p * this->q, this->q * other.q }; } rational_t operator - (rational_t other) const { return { this->p * other.q - other.p * this->q, this->q * other.q }; } rational_t operator * (rational_t other) const { return { this->p * other.p, this->q * other.q }; } rational_t operator / (rational_t other) const { return { this->p * other.q, this->q * other.p }; } }; rational_t make_rational(ll p, ll q) { return { p, q }; } constexpr int max_n = 7; struct loop_exception {}; bool solve(vector const & a) { array x; repeat (i, a.size()) x[i] = make_rational(a[i], 1); function go = [&](int n) { repeat (j,n) { swap(x[j], x[n-1]); repeat (i,j) { if (x[i] == x[n-1]) { throw loop_exception {}; } if (n == 2) continue; rational_t saved = x[i]; x[i] = saved + x[n-1]; go(n-1); x[i] = saved - x[n-1]; go(n-1); x[i] = saved * x[n-1]; go(n-1); if (x[n-1].p) { x[i] = saved / x[n-1]; go(n-1); } x[i] = saved; } swap(x[j], x[n-1]); } }; try { go(a.size()); } catch (loop_exception e) { return true; } return false; } int main() { int n; scanf("%d", &n); vector a(n); repeat (i,n) scanf("%d", &a[i]); bool found = solve(a); printf("%s\n", found ? "YES" : "NO"); return 0; }