#include <bits/stdc++.h>
using namespace std;
const long long mk = 200005;
const long long logn = 29;
const long long mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
int tc;
vector<int> g[mk];
int a[mk];
void init() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  if (a[1] != a[n])
    cout << 1;
  else
    cout << n;
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) init();
}
