#include <bits/stdc++.h>
using namespace std;
static int aQWEs = []() -> int {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  return 0;
}();
long long int power(long long int a, long long int p,
                    long long int m = 1000000007) {
  a %= m;
  long long int val = 1;
  while (p > 0) {
    if (p & 1) {
      val = (val * a) % m;
    }
    a = (a * a) % m;
    p >>= 1;
  }
  return (val);
}
int solve(vector<long long int> &v) {
  if (v.size() == 1) return 1;
  vector<long long int> st(v.size());
  int n = v.size();
  int l = 0;
  st[l++] = v[0];
  for (int i = 1; i < n; ++i) {
    st[l++] = v[i];
    while (l - 2 >= 0 && st[l - 1] != st[l - 2] || v[i] != v[i - 1]) {
      v[l - 2] += v[l - 1];
      l--;
    }
  }
  return l;
}
int main() {
  long long int n, i, j;
  long long int T = 1;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<long long int> v(n);
    for (i = 0; i < n; ++i) {
      cin >> v[i];
    }
    for (i = 1; i < n; ++i) {
      if (v[i] != v[i - 1]) break;
    }
    if (i == n) {
      cout << i << "\n";
    } else
      cout << 1 << "\n";
  }
}
