#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    set<long long> s;
    for (int i = 1; i <= n; i++) {
      long long x;
      scanf("%lld", &x);
      s.insert(x);
    }
    if (s.size() == 1)
      cout << n << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}
