#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
long long power(long long x, unsigned long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long _power(long long x, unsigned long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long invmod(long long a, long long m) { return _power(a, m - 2, m); }
void sieve(long long n, vector<bool> &prime) {
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
inline long long cl(long long a, long long b) {
  if (a % b) return 1 + a / b;
  return a / b;
}
signed main() {
  long long Tests = 1;
  cin >> Tests;
  while (Tests--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    bool diff = false;
    for (long long i = 0; i <= n - 1; i++) {
      cin >> v[i];
      if (i && v[i] != v[i - 1]) diff = true;
    }
    if (diff) {
      cout << 1 << "\n";
      ;
    } else {
      cout << n << "\n";
      ;
    }
  }
}
