#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    vector<long long> v(n);
    for (int j = 0; j < n; j++) {
      cin >> v[j];
    }
    sort(v.begin(), v.end());
    if (v[0] == v[n - 1]) {
      cout << n << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}
