#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    set<long long int> s;
    for (long long int i = 0; i < n; i++) s.insert(a[i]);
    if (s.size() == 1)
      cout << n << "\n";
    else
      cout << 1 << "\n";
  }
  return 0;
}
