#include <bits/stdc++.h>
using namespace std;
int place(vector<int> &a, int n) {
  int min = 101, sec_min = 101;
  for (int i = 0; i < n; i++)
    if (min > a[i]) min = a[i];
  for (int i = 0; i < n; i++)
    if (min != a[i] && a[i] < sec_min) sec_min = a[i];
  if (sec_min < 101)
    for (int i = 0; i < n; i++)
      if (min == a[i]) a[i] += ((sec_min - min) / 2) * 2;
  return ((sec_min - min) / 2) * 2;
}
int reduce(vector<int> &a, int n) {
  int min = 101;
  for (int i = 0; i < n; i++)
    if (min > a[i]) min = a[i];
  if (min > 0)
    for (int i = 0; i < n; i++) a[i] -= min;
  return min;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int testcase;
  cin >> testcase;
  int n;
  vector<int> a(100);
  while (testcase--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    while (reduce(a, n) > 0) {
      place(a, n);
    }
    bool flat = true;
    for (int i = 0; i < n; i++)
      if (a[i] > 0) {
        flat = false;
        break;
      }
    if (flat)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
