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