#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int ar[n];
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
  }
  if (mp.size() == 1)
    cout << n << "\n";
  else
    cout << 1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
