#include <bits/stdc++.h>
using namespace std;
const long long fix = (long long)1e9 + 7;
long long po2(long long a) {
  double temp = a;
  if (log2(temp) == (long long)log2(temp)) return log2(temp);
  return -1;
}
void tc(long long i) { cout << "Case #" << i + 1 << ": "; }
void yes() { cout << "YES" << '\n'; }
void no() { cout << "NO" << '\n'; }
void impb() { cout << "IMPOSSIBLE" << '\n'; }
long long ct() {
  long long t;
  scanf("%lld", &t);
  return t;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pwr(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2) x = (x * y) % fix;
    y = (y * y) % fix;
    b /= 2;
  }
  return x;
}
long long pmodinv(long long a) { return pwr(a, fix - 2); }
vector<vector<long long> > adj;
const long long N = 1e5 + 5;
bool visited[N] = {};
queue<long long> q;
long long comanc(long long u, long long v, long long parent[]) {
  while (u ^ v) {
    if (u == 1 || v == 1) return 1;
    u = parent[u];
    v = parent[v];
  }
  return u;
}
long long x;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
vector<long long> factorial((long long)4002);
long long nCr(long long n, long long k) {
  return (factorial[n] *
          ((pmodinv(factorial[k]) * pmodinv(factorial[n - k])) % fix)) %
         fix;
}
long long dsu_par[N];
long long sze[N];
void make_set(long long n) {
  for (long long j = (1); j < (n + 1); j++) {
    dsu_par[j] = j;
    sze[j] = 1;
  }
}
long long find_set(long long a) {
  if (dsu_par[a] == a) return a;
  return dsu_par[a] = find_set(dsu_par[a]);
}
void union_set(long long a, long long b) {
  a = find_set(a);
  b = find_set(b);
  if (a ^ b) {
    if (sze[a] < sze[b]) swap(a, b);
    dsu_par[b] = a;
    sze[a] += sze[b];
  }
}
map<pair<long long, long long>, long long> mp;
vector<vector<long long> > up;
vector<long long> tin, tout;
long long dfs_timer = 0;
long long lim;
long long dist[N] = {};
void _dfs(long long v, long long par) {
  tin[v] = ++dfs_timer;
  up[v][0] = par;
  for (long long j = (1); j < (lim + 1); j++)
    up[v][j] = up[up[v][j - 1]][j - 1];
  for (long long u : adj[v]) {
    if (u ^ par) {
      dist[u] = dist[v] + mp.find(pair<long long, long long>(u, v))->second;
      _dfs(u, v);
    }
  }
  tout[v] = ++dfs_timer;
}
bool is_anc(long long u, long long v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
long long lca(long long u, long long v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (long long i = lim; i >= 0; i--)
    if (is_anc(up[u][i], v) ^ 1) u = up[u][i];
  return up[u][0];
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long bisearch(vector<pair<long long, long long> >& operate,
                   long long limit) {
  long long lo = 0, hi = operate.size() - 1;
  while (lo < hi) {
    long long mid = lo + (hi - lo + 1) / 2;
    if (operate[mid].first > limit)
      hi = mid - 1;
    else
      lo = mid;
  }
  return lo;
}
int32_t main() {
  long long t = 1;
  t = ct();
  for (long long ii = (0); ii < (t); ii++) {
    long long n = ct();
    long long arr[n];
    for (long long j = (0); j < (n); j++) {
      cin >> arr[j];
    }
    long long cnt = 1;
    for (long long j = (1); j < (n); j++) {
      if (arr[j] == arr[0]) cnt++;
    }
    if (cnt == n)
      cout << n << '\n';
    else
      cout << "1" << '\n';
  }
}
