Perfect square of $n$ primes in $2^n$ row Let $p_1, p_2, p_3, p_4$ be prime numbers. The state is:we can't put them in row $p_{i_1}, p_{i_2}, \ldots, p_{i_{16}}$, $p_{i_j} \in \{p_1, p_2, p_3, p_4 \}$ so that $$ \prod_{j = m}^{n} p_{i_j} \not = q^2$$ for $1 \leq m < n \leq 16 $, $q \in \mathbb{N}?$ Is there any good invariant proof? It seems that this fact is true even for $n$ primes and $2^n$ lenght row.
 A: Assuming my rephrase in the comments is correct. If not, I will delete this answer.
I am not sure how to directly write the proof in math notation, so I will give a short example. let the primes be $2, 3, 5, 7$ and the row be
$$2, 5, 3, 3, 5, 2, 7, 7, 3, 7, 5, 2, 3, 5, 2, 7$$
We have that the product of term 2 to 5 is $5\cdot 3\cdot3\cdot 5=15^2$, as well as many other intervals (9 to 16 for example)

Let's rewrite the primes as four vectors - $(1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0)$ and $(0, 0, 0, 1)$. Then the multiplication/product operation
can be replaced by an addition operation under $\mod 2$ ($\mathbb{Z}_2$). Moreover, the requirement of $\prod_{i=s}^e r_i \neq q^2$ can be rephrased as $\sum_{i=s}^e r_i \neq \vec{0}$. For example, term 2 to 5's sum is $$\underbrace{(0,0,1,0)}_5+\underbrace{(0,1,0,0)}_3+\underbrace{(0,1,0,0)}_3+\underbrace{(0,0,1,0)}_5=(0,0,0,0)\mod 2$$
The next step is to rewrite the sum into the difference of prefix sum. This is done like this:
$$\sum_{i=s}^e r_i=\sum_{i=1}^e r_i - \sum_{i=1}^{s-1} r_i$$
The requirement $\sum_{i=s}^e r_i\neq \vec{0}$ can again be rephrased as $$\sum_{i=1}^e r_i \neq \sum_{i=1}^{s-1} r_i$$
Notice that both of the terms are in the form of $\sum_{i=1}^{x} r_i$, where $0\leq x\leq 16$.
Finally, the sum is a vector of length 4 with each element in $\{0, 1\}$, so there is at most $2^4=16$ choices of $\sum_{i=1}^{x} r_i$.
Since there are essentially $17$ terms with $0\leq x\leq 16$, by pigeonhole principle there must be two prefix-sums that are the same, or equivalent that in the original question, there exists a subinterval for which its product is a perfect square.

Again, sorry for the bad english, but if you don't understand feel free to ask and I will add on to my current answer.
Gareth
A: $\prod_{j = 1}^{n} p_{i_j} $ will have odd power of one or more prime for $1\le n\le16$ otherwise we are done.
Among 4 primes number of ways you can have odd power of one or more prime$=2^4-1=15$. Example of one of the ways will be $p_1,p_2$ having odd powers in the product, another example would be $p_2,p_3,p_4$ having odd powers in the product.
Then by pigeon  hole principal there exists $a> b$ such that $
\prod_{j = 1}^{a} p_{i_j}$ and $\prod_{j = 1}^{b} p_{i_j}$ have same primes with odd power.
Then $\frac{\prod_{j = 1}^{a} p_{i_j} }{\prod_{j = 1}^{b} p_{i_j} }=\prod_{j = b-1}^{a} p_{i_j} $ will be a square.
