#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t, i, s, b, x;
  cin >> t;
  while (t--) {
    b = 0;
    cin >> n;
    int arr[n];
    for (i = 0; i < n; i++) {
      cin >> arr[i];
    }
    x = arr[0];
    for (i = 0; i < n; i++) {
      if (arr[i] != x) {
        b = 1;
        cout << 1 << endl;
        break;
      }
    }
    if (b == 0) {
      cout << n << endl;
    }
  }
}
