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