#include <bits/stdc++.h>
using namespace std;
int spf[1000005];
vector<int> primes;
void sieve() {
  for (long long i = 2; i < 1000005; ++i) {
    if (spf[i] == 0) {
      spf[i] = i;
      for (int j = 2 * i; j <= 1000005; j += i) {
        if (spf[j] == 0) spf[j] = i;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(static_cast<unsigned>(time(0)));
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a;
    for (long long i = 0; i < n; ++i) {
      long long x;
      cin >> x;
      a.push_back(x);
    }
    long long c = 0;
    for (long long i = 0; i < n - 1; ++i) {
      if (a[i] == a[i + 1]) c++;
    }
    if (c == (n - 1))
      cout << n << '\n';
    else
      cout << 1 << '\n';
  }
  return 0;
}
