#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, i;
  cin >> n;
  int ara[n];
  for (int i = 0; i < n; ++i) {
    cin >> ara[i];
  }
  for (i = 1; i < n; i++) {
    if (ara[i] != ara[i - 1]) {
      cout << "1\n";
      return;
    }
  }
  cout << n << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
