#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    bool flag = true;
    int lst;
    cin >> lst;
    for (int i = 2; i <= n; i++) {
      int x;
      cin >> x;
      if (x != lst) flag = false;
    }
    if (!flag)
      cout << 1 << endl;
    else
      cout << n << endl;
  }
  return 0;
}
