#include <bits/stdc++.h>
using namespace std;
int main() {
  int c, t, n;
  cin >> t;
  for (c = 1; c <= t; c++) {
    int i, j, k, l, m, o;
    o = 0;
    cin >> n;
    int arr[n - 1];
    for (i = 0; i <= (n - 1); i++) {
      cin >> arr[i];
    }
    for (m = 0; m <= (n - 1); m++) {
      if (arr[m] == arr[0]) {
        o++;
      }
    }
    if (o != n) {
      cout << 1 << "\n";
    } else {
      cout << n << "\n";
    }
  }
  return 0;
}
