#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI = acos(-1);
const int INF = 1e9;
int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
void solve() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  set<long long> st;
  for (long long i = 0; i < n; i++) st.insert(arr[i]);
  if (st.size() == 1)
    cout << n << endl;
  else
    cout << 1 << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return (0);
}
