## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Add Modulo 10 Codeforces Solution

E. Add Modulo 10
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array of $n$ integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$

You can apply the following operation an arbitrary number of times:

• select an index $i$ ($1\le i\le n$) and replace the value of the element ${a}_{i}$ with the value ${a}_{i}+\left({a}_{i}mod10\right)$, where ${a}_{i}mod10$ is the remainder of the integer dividing ${a}_{i}$ by $10$.

For a single index (value $i$), this operation can be applied multiple times. If the operation is applied repeatedly to the same index, then the current value of ${a}_{i}$ is taken into account each time. For example, if ${a}_{i}=47$ then after the first operation we get ${a}_{i}=47+7=54$, and after the second operation we get ${a}_{i}=54+4=58$.

Check if it is possible to make

Solution Click Below:-  👉

👇👇👇👇👇

occupied

all array elements equal by applying multiple (possibly zero) operations.

For example, you have an array $\left[6,11\right]$.

• Let's apply this operation to the first element of the array. Let's replace ${a}_{1}=6$ with ${a}_{1}+\left({a}_{1}mod10\right)=6+\left(6mod10\right)=6+6=12$. We get the array $\left[12,11\right]$.
• Then apply this operation to the second element of the array. Let's replace ${a}_{2}=11$ with ${a}_{2}+\left({a}_{2}mod10\right)=11+\left(11mod10\right)=11+1=12$. We get the array $\left[12,12\right]$.

Thus, by applying $2$ operations, you can make all elements of an array equal.

Input

The first line contains one integer $t$ ($1\le t\le {10}^{4}$) — the number of test cases. What follows is a description of each test case.

The first line of each test case contains one integer $n$ ($1\le n\le 2\cdot {10}^{5}$) — the size of the array.

The second line of each test case contains $n$ integers ${a}_{i}$ ($0\le {a}_{i}\le {10}^{9}$) — array elements.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot {10}^{5}$.

Output

For each test case print:

• YES if it is possible to make all array elements equal;
• NO otherwise.

You can print YES and NO in any case (for example, the strings yEsyesYes and YES will be recognized as a positive answer) .