#include <bits/stdc++.h>
struct arr {
  int n;
  int *a;
} arr;
int main() {
  int n;
  scanf("%d", &n);
  struct arr A[n];
  int res[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i].n);
    A[i].a = (int *)malloc(A[i].n * sizeof(int));
    for (int j = 0; j < A[i].n; j++) scanf("%d", &A[i].a[j]);
  }
  for (int k = 0; k < n; k++) {
    int flag = 1;
    for (int j = 0; j < A[k].n - 1; j++)
      if (A[k].a[j] != A[k].a[j + 1]) {
        flag = 0;
        break;
      }
    if (flag)
      res[k] = A[k].n;
    else
      res[k] = 1;
  }
  for (int k = 0; k < n; k++) printf("%d\n", res[k]);
}
