#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1000000000000000000;
const long double PI = 3.1415926535897932384626;
const long double eps = 1e-12;
void __print(int32_t x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(float x) { cout << x; }
void __print(bool x) { cout << (x ? "true" : "false"); }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char *x) { cout << '\"' << x << '\"'; }
void __print(const string &x) { cout << '\"' << x << '\"'; }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
long long power(long long base, long long exp) {
  long long res = 1;
  base %= mod;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % mod;
    base = (base * base) % mod;
    exp = exp >> 1;
  }
  return res;
}
long long inv(long long x) { return power(x, mod - 2) % mod; }
const long long N = 1e6 + 6, M = N;
long long i, j;
void solve() {
  long long n;
  cin >> n;
  set<long long> s;
  for (i = 0; i < n; i++) {
    long long a;
    cin >> a;
    s.insert(a);
  }
  if ((long long)s.size() == 1)
    cout << n << '\n';
  else
    cout << 1 << '\n';
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
