#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t, n, hold;
  cin >> t;
  while (t--) {
    bool ans = false;
    cin >> n;
    long long int x;
    for (long long int i = 0; i < n; i++) {
      cin >> hold;
      if (i == 0) x = hold;
      if (x != hold) ans = true;
    }
    if (ans)
      cout << 1 << endl;
    else
      cout << n << endl;
  }
  return 0;
}
