#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  bool ok = true;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0) {
      ok &= (a[i] == a[i - 1]);
    }
  }
  if (ok) {
    cout << n << "\n";
  } else {
    cout << 1 << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
