#include <bits/stdc++.h>
using namespace std;
mt19937 mrand(43);
const double PI = acos((double)-1);
const double eps = 1e-5;
const long long inf0 = 1023 * 1024 * 1024;
const long long inf = inf0 * inf0;
const long long mod = 1e9 + 7;
void solve();
void scan();
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed;
  cout.precision(15);
  solve();
  return 0;
}
void solve() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    int f = a[0];
    bool fl = true;
    for (int i = 0; i < n; i++) {
      if (a[i] != f) fl = false;
    }
    if (fl)
      cout << n << '\n';
    else
      cout << 1 << '\n';
  }
  return;
}
