#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long qpw(long long a, long long b, long long p) {
  a %= p;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return ans % p;
}
int cc;
long long a[MAXN];
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> cc;
  while (cc--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int f = 1;
    for (int i = 1; i < n; i++) {
      if (a[i] == a[0]) f++;
    }
    if (f == n)
      cout << n << endl;
    else
      cout << "1" << endl;
  }
  return 0;
}
