#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  for (const auto &x : v) os << " " << x;
  return os << '}';
}
void solve() {
  int n;
  cin >> n;
  int in;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> in;
    mp[in]++;
  }
  if (mp[in] == n)
    cout << n << endl;
  else
    cout << "1" << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int test_cases;
  cin >> test_cases;
  for (int tc = 1; tc <= test_cases; tc++) {
    solve();
  }
  return 0;
}
