#include <bits/stdc++.h>
using namespace std;
long long a[200012], h;
bool x;
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  long long n;
  while (t--) {
    cin >> n;
    cin >> h;
    x = 0;
    for (long long i = 2; i <= n; i++) {
      cin >> a[i];
      if (h != a[i]) {
        x = 1;
      }
    }
    if (x) {
      cout << 1;
    } else {
      cout << n;
    }
    cout << "\n";
  }
}
