#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  bool ok = false;
  int x, y;
  for (int i = 0; i < n; ++i) {
    if (i == 0)
      scanf("%d", &x);
    else {
      scanf("%d", &y);
      if (x != y) ok = true;
    }
  }
  printf("%d\n", ok ? 1 : n);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  for (int _ = 1; _ <= t; _++) {
    solve();
  }
  return 0;
}
