Cubelover

Time limit1sMemory limit128 MB

Summary
Given a sequence, decide whether real coefficients a, b, c, d exist so that x_i equals a*i^3 + b*i^2 + c*i + d for every position i.
Level

Medium4 of 10

Topics
Math, Implementation, Brute force
Solved
No attempts yet

Problem

Jihak is a well-known cubelover: he loves cubic polynomials.

One sunny spring day, Jihak spotted Seunghyun playing with an integer sequence x1,x2,…,xnx_1, x_2, \ldots, x_n of length nn at the apartment-complex playground. Jihak was the boss of that apartment complex, and he was Seunghyun's elder brother in spirit, born a full 45 days before him. The moment Jihak saw Seunghyun, he snatched the sequence away.

Seunghyun broke down crying on the spot. His heart softening, Jihak promised to return the sequence if Seunghyun could find real numbers aa, bb, cc, dd such that

xi=ai3+bi2+ci+dx_i = a i^3 + b i^2 + c i + d

holds for every integer ii with 1≤i≤n1 \le i \le n. (Strictly speaking a cubic polynomial requires a≠0a \ne 0, but Jihak does not seem to want to be that strict, so a=0a = 0 is allowed as well.)

Out enjoying a rare day away from school, you met eyes with the sobbing Seunghyun. He ran straight up to you and begged you to find such real numbers aa, bb, cc, dd as quickly as possible. Can you wipe away Seunghyun's tears?

Input

The input contains several test cases. The first line contains the number of test cases TT (1≤T≤10001 \le T \le 1000).

Each of the next TT lines describes one test case. It begins with an integer nn (1≤n≤5001 \le n \le 500), the length of the sequence, followed by nn integers; the ii-th of them is xix_i (0≤xi≤50 000 0000 \le x_i \le 50\,000\,000).

Output

For each test case, print YES if real numbers aa, bb, cc, dd satisfying xi=ai3+bi2+ci+dx_i = a i^3 + b i^2 + c i + d exist, and NO otherwise. Print one answer per line.

Hint

In the first test case, one possible answer is a=0a = 0, b=0b = 0, c=0c = 0, d=3d = 3.

Examples1

  1. Example 1

    Input
    3
    1 3
    5 0 1 2 3 4
    5 0 1 2 4 5
    
    Expected output
    YES
    YES
    NO