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