#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  cin >> t;
  for (int z = 1; z <= t; z++) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    int res = n;
    for (int i = 1; i < n; i++) {
      if (a[i] != a[i + 1]) {
        res = 1;
        break;
      }
    }
    cout << res << "\n";
  }
  return 0;
}
