#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n;
    set<int> te;
    for (int i = (0); i < n; i++) {
      cin >> x;
      te.insert(x);
    }
    if (te.size() > 1)
      cout << "1\n";
    else
      cout << n << "\n";
  }
}
