#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  for (cin >> t; t--;) {
    int n;
    cin >> n;
    vector<int> a(n);
    bool all_equal = true;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i >= 1 and a[i] != a[i - 1]) {
        all_equal = false;
      }
    }
    if (all_equal) {
      cout << n << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}
