#include <bits/stdc++.h>
using namespace std;
const long long N = 1e+9 + 7;
const long long M = 3e+5 + 8;
long long a[M];
int main() {
  long long t, n;
  cin >> t;
  while (t--) {
    int count = 0;
    cin >> n;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      if (i > 1 && a[i] != a[i - 1]) count = 1;
    }
    if (count)
      cout << 1;
    else
      cout << n;
    cout << "\n";
  }
  return 0;
}
