#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long i, j, n, m, k, x = 0, y, w, z, o = 0, flag = 0, count = 0;
    cin >> n;
    long long a[n];
    cin >> a[0];
    for (i = 1; i < n; i++) {
      cin >> a[i];
      if (a[i] != a[i - 1]) flag++;
    }
    if (flag > 0)
      cout << "1\n";
    else
      cout << n << "\n";
  }
  return 0;
}
