#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  set<long long> s;
  long long x;
  for (long long i = 0; i < n; ++i) cin >> x, s.insert(x);
  printf("%lld\n", (s.size() == 1) ? n : 1);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
