#include <bits/stdc++.h>
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
int a[200005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int ok = 1;
    for (int i = 1; i <= n; ++i)
      if (a[i] != a[1]) ok = 0;
    if (ok)
      cout << n << endl;
    else
      cout << 1 << endl;
  }
}
