#include <bits/stdc++.h>
using namespace std;
int a[2000010];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int ok = 1;
    for (int i = 2; i <= n; i++) {
      if (a[i] != a[i - 1]) {
        ok = 0;
        break;
      }
    }
    if (ok)
      printf("%d\n", n);
    else
      printf("1\n");
  }
  return 0;
}
