#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
      cin >> A[i];
    }
    int x = A[0];
    int fl = -1;
    for (int i = 0; i < N; i++) {
      if (A[i] != x) fl = 0;
    }
    if (fl == -1)
      cout << N << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}
