#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
void solve() {
  int n;
  cin >> n;
  vector<int> r(n);
  bool iguales = true;
  int base;
  for (int i = 0; i < n; i++) {
    cin >> r[i];
    if (i == 0)
      base = r[i];
    else {
      if (r[i] != base) iguales = false;
    }
  }
  if (iguales)
    cout << n << "\n";
  else
    cout << 1 << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
