#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
  }
  sort((vec).begin(), (vec).end());
  if (vec.front() == vec.back())
    cout << n << "\n";
  else
    cout << "1\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int nbTests;
  cin >> nbTests;
  for (int iTest = 0; iTest < nbTests; ++iTest) {
    solve();
  }
}
