#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, mx, d;
  cin >> t;
  while (t--) {
    cin >> n;
    set<long long> s;
    mx = n;
    while (n--) {
      cin >> d;
      s.insert(d);
    }
    if (s.size() == 1)
      cout << mx << "\n";
    else
      cout << 1 << "\n";
  }
}
