#include <bits/stdc++.h>
using namespace std;
long long fact_a[1000005];
long long factorial() {
  fact_a[0] = fact_a[1] = 1;
  for (long long i = 2; i < 1000005; i++) fact_a[i] = (fact_a[i - 1] * i);
}
long long power(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = result * x;
    x = x * x;
    n = n / 2;
  }
  return result;
}
long long nCr(long long n, long long r) {
  if (n < r) return 0LL;
  if (n == r) return 1LL;
  long long ans = fact_a[n];
  ans = (ans * power(fact_a[r], 1000000007 - 2)) % 1000000007;
  ans = (ans * power(fact_a[n - r], 1000000007 - 2)) % 1000000007;
  return ans;
}
long long prime[1000005];
void sieve() {
  prime[1000005] = {0};
  for (long long i = 2; i < 1000005; i++) {
    if (prime[i] == 0) {
      for (long long j = i * i; j < 1000005; j += i) {
        prime[j] = 1;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, k;
    cin >> n;
    long long a[n];
    set<long long> s;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      s.insert(a[i]);
    }
    if (s.size() == 1)
      cout << n << '\n';
    else
      cout << 1 << '\n';
  }
}
