#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    int n, x, y, z = 0, temp;
    cin >> n;
    cin >> x;
    temp = n;
    while (temp > 1) {
      cin >> y;
      if (x != y) z = 1;
      temp--;
    }
    if (z == 1) {
      cout << 1 << endl;
    } else {
      cout << n << endl;
    }
  }
  return 0;
}
