#include <bits/stdc++.h>
using namespace std;
using Long = long long;
using Double = long double;
const int N = 2e5 + 5;
int v[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> v[i];
  bool ok = true;
  for (int i = 0; i < n - 1; ++i) ok &= v[i] == v[i + 1];
  if (ok)
    cout << n << '\n';
  else
    cout << 1 << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) solve();
  return 0;
}
