#include <bits/stdc++.h>
const double PI = 3.141592653589793238460;
const long long int MOD = 1000000007;
using namespace std;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int t;
  scanf("%d", &t);
  for (int q = 1; q <= t; q++) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = int(0); i <= int(n - 1); i++) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] == a[n - 1])
      cout << n << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}
