#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
using namespace std;
const long long MOD = 1000000007;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    set<int> s;
    for (long long i = (0); i < (n); i++) {
      int x;
      cin >> x;
      s.insert(x);
    }
    if (s.size() == 1) {
      cout << n << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}
