#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-10;
const unsigned long long hashp = 131;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int maxn = 2e5 + 100;
int a[maxn];
void solve() {
  int _;
  scanf("%d", &_);
  while (_--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; (i) <= (n); i++) scanf("%d", &a[i]);
    int ans = 1;
    for (int i = 2; i <= n; i++) {
      if (a[i] != a[1]) ans = 0;
    }
    if (ans)
      printf("%d\n", n);
    else
      printf("%d\n", 1);
  }
}
int main() {
  solve();
  return 0;
}
