#include <bits/stdc++.h>
using namespace std;
const int long long N = 2e5 + 1;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int long long t;
  cin >> t;
  while (t--) {
    int long long n;
    cin >> n;
    vector<int long long> v(n);
    for (int long long i = 0; i < n; i++) cin >> v[i];
    map<int long long, int long long> m;
    for (int long long i = 0; i < n; i++) {
      m[v[i]]++;
    }
    int long long cnt = 0;
    if (m.size() > 1)
      cout << 1;
    else
      cout << n;
    cout << "\n";
  }
  return 0;
}
