#include <bits/stdc++.h>
using namespace std;
int solve(vector<long long> &v, int n) {
  int flag = 0;
  for (int i = 0; i < n - 1; i++) {
    if (v[i] != v[i + 1]) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    return 1;
  else
    return n;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> v;
    for (int i = 0; i < n; i++) {
      long long x;
      cin >> x;
      v.push_back(x);
    }
    cout << solve(v, n) << "\n";
  }
  return 0;
}
