#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  ;
  cin >> t;
  while (t--) {
    int s;
    vector<int> v;
    cin >> s;
    for (int i = 0; i < s; i++) {
      int x;
      cin >> x;
      v.push_back(x);
    }
    int f = 0;
    for (int i = 0; i < s - 1; i++) {
      if (v[i] != v[i + 1]) f = 1;
    }
    if (f == 1)
      cout << "1" << endl;
    else
      cout << s << endl;
  }
  return 0;
}
