#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    if (arr[0] != arr[n - 1])
      cout << "1\n";
    else
      cout << n << "\n";
  }
  return 0;
}
