Under construction

Still being built. Things may change

Factoring a Polynomial

Time limit1sMemory limit512 MB

Summary
Given a polynomial with integer coefficients of degree at most 20, decide whether it is irreducible over the reals.
Level

Easy3 of 10

Topics
Math, Implementation, Brute force
Solved
No attempts yet

Problem

A polynomial in one variable can be written as the formal sum anxn+an−1xn−1+⋯+a1x+a0a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0, where xx is the formal variable and the numbers aia_i are its coefficients. The largest index ii with ai≠0a_i \neq 0 is called the degree of the polynomial; if ai=0a_i = 0 for every ii, the degree is defined to be −∞-\infty. A polynomial whose degree is 00 or −∞-\infty is called trivial; any other polynomial is non-trivial.

A polynomial with real coefficients is called irreducible if it cannot be written as a product of two or more non-trivial polynomials with real coefficients; otherwise it is called reducible. For instance, x2−2x+1x^2 - 2x + 1 is reducible because x2−2x+1=(x−1)(x−1)x^2 - 2x + 1 = (x - 1)(x - 1), whereas x2+1x^2 + 1 is irreducible. It is a classical fact that every polynomial can be written as a product of one or more irreducible polynomials.

Given a polynomial with integer coefficients, determine whether it is irreducible over the real numbers.

Input

The first line contains the degree nn of the polynomial (0≤n≤200 \le n \le 20).

The second line contains n+1n + 1 integers an,an−1,…,a1,a0a_n, a_{n-1}, \ldots, a_1, a_0 — the coefficients of the polynomial (−1000≤ai≤1000-1000 \le a_i \le 1000, an≠0a_n \neq 0).

Output

Print YES if the polynomial is irreducible over the real numbers, and NO otherwise.

Examples2

  1. Example 1

    Input
    2
    1 -2 1
    
    Expected output
    NO
    
  2. Example 2

    Input
    2
    1 0 1
    
    Expected output
    YES