#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n, 0);
  for (long long int i = 0; i < n; ++i) cin >> arr[i];
  if (*min_element(arr.begin(), arr.end()) ==
      *max_element(arr.begin(), arr.end()))
    cout << n << '\n';
  else
    cout << 1 << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  auto start1 = high_resolution_clock::now();
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
  return 0;
}
