#include <bits/stdc++.h>
int a[200010];
int main() {
  int t, n, i, cnt;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    cnt = 1;
    for (i = 2; i <= n; i++)
      if (a[i] == a[1]) cnt++;
    if (cnt == n)
      printf("%d\n", n);
    else
      printf("1\n");
  }
}
