#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1000000000000000000;
const long long int mod = 1E9 + 7;
void solve() {
  long long int t;
  cin >> t;
  while (t > 0) {
    long long int n;
    cin >> n;
    long long int ent;
    set<long long int> s;
    for (int i = 0; i < n; i++) {
      cin >> ent;
      s.insert(ent);
    }
    if (s.size() == 1) {
      cout << n << endl;
    } else {
      cout << 1 << endl;
    }
    t--;
  }
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  ;
  solve();
}
