#include <bits/stdc++.h>
using namespace std;
long long t, c = 0;
int main() {
  cin >> t;
  while (t--) {
    long long x = 0, res = 0, flag = 0, z = 0;
    long long n;
    cin >> n;
    vector<long long> a;
    for (long long i = 0; i < n; i++) {
      cin >> x;
      a.push_back(x);
    }
    unordered_set<int> s;
    for (long long i = 0; i < n; i++) {
      if (s.find(a[i]) == s.end()) {
        s.insert(a[i]);
        res++;
      }
    }
    long long tot = n - res;
    if (res == 1)
      cout << n << endl;
    else
      cout << 1 << endl;
  }
}
