#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    bool flag = true;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      sum = sum + a[i];
    }
    for (long long i = 0; i < n - 1; i++) {
      if (a[i] != a[i + 1]) {
        flag = false;
      }
    }
    if (flag == true)
      cout << n << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}
