#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long tests = 1LL;
  cin >> tests;
  for (int testno = 1; testno < tests + 1; testno++) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    long long sum = 0;
    set<long long> s;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      s.insert(a[i]);
    }
    if ((int)s.size() == 1)
      cout << n << '\n';
    else
      cout << "1" << '\n';
  }
  return 0;
}
