#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
      cin >> x;
      s.insert(x);
    }
    if ((int)s.size() == 1)
      cout << n;
    else
      cout << 1;
    cout << endl;
  }
}
