#include <bits/stdc++.h>
using namespace std;
const int N = 2000009;
int n, a[N];
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}
void work() {
  int T;
  scanf("%d", &T);
  while (T--) {
    init();
    int flag = 1;
    for (int i = 2; i <= n; i++)
      if (a[i] != a[1]) {
        flag = 0;
        break;
      }
    if (flag)
      printf("%d\n", n);
    else
      puts("1");
  }
}
int main() {
  work();
  return 0;
}
