#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long m = 1e9 + 7;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int k;
    cin >> k;
    int d = 0;
    for (int i = 1; i < n; i++) {
      int x;
      cin >> x;
      if (k == x) d++;
    }
    if (d == n - 1)
      cout << n << endl;
    else
      cout << 1 << endl;
  }
}
