Lord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!

A password is an array $a$ of $n$ positive integers. You apply the following operation to the array: pick any two adjacent numbers that are not equal to each other and replace them with their sum. Formally, choose an index $i$ such that $1 \leq i < n$ and $a_{i} \neq a_{i+1}$, delete both $a_i$ and $a_{i+1}$ from the array and put $a_{i}+a_{i+1}$ in their place. 

For example, for array $[7, 4, 3, 7]$ you can choose $i = 2$ and the array will become $[7, 4+3, 7] = [7, 7, 7]$. Note that in this array you can't apply this operation anymore.

Notice that one operation will decrease the size of the password by $1$. What is the shortest possible length of the password after some number (possibly $0$) of operations?


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). Description of the test cases follows.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 2 \cdot 10^5$) — the length of the password.

The second line of each test case contains $n$ integers $a_{1},a_{2},\dots,a_{n}$ ($1 \leq a_{i} \leq 10^9$) — the initial contents of your password.

The sum of $n$ over all test cases will not exceed $2 \cdot 10^5$.


-----Output-----

For each password, print one integer: the shortest possible length of the password after some number of operations.


-----Example-----
Input
2
4
2 1 3 1
2
420 420

Output
1
2



-----Note-----

In the first test case, you can do the following to achieve a length of $1$:

Pick $i=2$ to get $[2, 4, 1]$

Pick $i=1$ to get $[6, 1]$

Pick $i=1$ to get $[7]$

In the second test case, you can't perform any operations because there is no valid $i$ that satisfies the requirements mentioned above.

Difficulty: MEDIUM

Starter code:

Solutions:
import sys
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ri = lambda : int(sys.stdin.readline().strip())
rs = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
import random
from queue import PriorityQueue as pq
from math import ceil
t = ri()
for _ in range(t):
	n = ri()
	l = RI()
	s = set(l)
	if len(s) == 1:
		print(n)
	else:
		print(1)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	dic = Counter(arr)
	if len(dic) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = set(map(int, input().split()))
	if len(arr) == 1:
		print(n)
	else:
		print(1)


def solve(a, n):
	(s, i) = ([], 0)
	while i < len(a):
		if len(s) == 0:
			s.append(a[i])
		elif s[-1] == a[i]:
			s.append(a[i])
		else:
			prev = s.pop()
			s.append(prev + a[i])
		i += 1
	while len(s) > 1:
		if s[-1] != s[-2]:
			s1 = s.pop()
			s2 = s.pop()
			s.append(s1 + s2)
		else:
			break
	return len(s)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(min(solve(a, n), solve(a[::-1], n)))


import math
import os
import random
import re
import sys
from collections import defaultdict, Counter, deque
import heapq
from functools import lru_cache
from itertools import accumulate, chain, combinations, permutations, groupby, zip_longest
from math import floor, ceil, sqrt

def solve(arr):
	s = set(arr)
	if len(s) == 1:
		return len(arr)
	else:
		return 1
t = int(input())
results = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	results += (solve(arr),)
for res in results:
	print(res)


from functools import reduce

def f():
	t = int(input())
	for _ in range(t):
		n = input()
		arr = list(map(lambda x: int(x), input().split()))
		eq = arr[0]
		boolist = list(map(lambda x: x == eq, arr))
		if reduce(lambda x, y: x and y, boolist):
			print(n)
		else:
			print(1)
f()


import sys
input = lambda : sys.stdin.readline()[:-1]
from collections import Counter

def main():
	t = int(input())
	for case in range(t):
		n = int(input())
		A = Counter([int(x) for x in input().split()])
		if len(A) == 1:
			print(n)
		else:
			print(1)
	return
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 0
	for i in range(n - 1):
		if l[i + 1] != l[i]:
			flag = 1
			break
	if flag == 0:
		print(n)
	else:
		print(1)


def answer(n, A):
	d = {}
	for i in range(n):
		if A[i] in d:
			d[A[i]] += 1
		else:
			d[A[i]] = 1
	if len(d) == 1:
		return n
	else:
		return 1
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(answer(n, arr))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) != 1:
		print(1)
	else:
		print(len(l))


try:
	from sys import stdin, stdout
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		a = list(map(int, stdin.readline().split()))
		if set(a) == {a[0]}:
			stdout.write(str(len(a)) + '\n')
		else:
			stdout.write('1\n')
except:
	pass


for _ in range(int(input())):
	n = int(input())
	a = []
	a[0:n] = map(int, input().split())
	count = 0
	x = a[0]
	for i in range(n):
		if x == a[i]:
			count += 1
		else:
			count = 0
			break
	if count > 0:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if max(arr) != min(arr):
		print(1)
	else:
		print(n)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		if len(set(a)) == 1:
			print(n)
		else:
			print(1)
main()


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	if len(set(A)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
while t:
	n = int(input())
	a = input().split()
	a = set(map(int, a))
	if len(a) == 1:
		print(n)
	else:
		print(1)
	t -= 1


T = int(input())
for i in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print(len(arr))
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


n = int(input())
for _ in range(n):
	a = int(input())
	arr = list(map(int, input().split(' ')))
	val = list(set(arr))
	if a == 1:
		print(1)
	elif a == 2:
		if arr[0] == arr[1]:
			print(2)
		else:
			print(1)
	elif len(val) == 1:
		print(len(val) * a)
	else:
		print(1)


def sol():
	n = int(input())
	arr = list(map(int, input().split()))
	past = arr[0]
	flag = False
	for i in range(n):
		if past != arr[i]:
			flag = True
	if flag:
		print(1)
	else:
		print(n)
for _ in range(int(input())):
	sol()


import sys, math
from heapq import *
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	pw = list(map(int, sys.stdin.readline().split()))
	out = n
	for i in range(1, n):
		if pw[i] != pw[i - 1]:
			out = 1
	print(out)


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a = sorted(a)
	if a[0] != a[-1]:
		print('1')
	else:
		print(len(a))


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	x = a.count(a[0])
	if x == n:
		print(n)
	else:
		print(1)


for i in range(int(input())):
	x = int(input())
	A = list(map(int, input().split()))
	A.sort()
	if A[0] == A[-1]:
		print(len(A))
	else:
		print(1)


for i in range(int(input())):
	p = int(input())
	s = list(map(int, input().split()))
	if len(set(s)) == 1:
		print(len(s))
	else:
		print(1)


from collections import defaultdict

def ii():
	return int(input())

def si():
	return input()

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())
t = ii()
for _ in range(t):
	n = ii()
	l = li()
	b = True
	for i in range(n):
		if i != 0:
			if l[i] != l[i - 1]:
				b = False
	if b:
		print(n)
	else:
		print(1)


for j in range(int(input())):
	a = int(input())
	b = list(map(int, input().strip().split()))[:a]
	c = set(b)
	if len(c) == 1:
		print(a)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	l = [int(s) for s in input().split()]
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = arr.count(arr[0])
	if x == n:
		print(n)
	else:
		print(1)


t = int(input())
for k in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if a.count(a[0]) == n:
		print(n)
	else:
		print(1)


def oamkarPassword(array):
	array.sort()
	if array[0] == array[-1]:
		return len(array)
	return 1
for _ in range(int(input())):
	n = input()
	array = [int(i) for i in input().split()]
	print(oamkarPassword(array))


t = int(input())
for i in range(t):
	s = int(input())
	p = list(map(int, input().split()))
	if s == 1:
		print(1)
		continue
	status = True
	for j in range(s - 1):
		if p[j] != p[j + 1]:
			status = False
			break
	if status:
		print(s)
		continue
	print(1)


for i in [0] * int(input()):
	input()
	x = input().split()
	c = len(set(x))
	print([1, len(x)][c == 1])


def omkar_pass(arr):
	if len(set(arr)) == 1:
		return len(arr)
	else:
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(omkar_pass(arr))


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(set(l))
	if len(s) == 1:
		print(n)
	else:
		print(1)


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	ln = len(set(s))
	if ln == 1:
		print(len(s))
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	check = 0
	for i in range(1, n):
		if a[i] != a[0]:
			check = 1
			break
	if check:
		print(1)
	else:
		print(n)


import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	if len(s) == 1:
		print(n)
	else:
		print(1)
	t -= 1


import sys
from collections import defaultdict
t = 1
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, sys.stdin.readline().strip().split()))
	f = 1
	for j in range(n - 1):
		if a[j] == a[j + 1]:
			continue
		f = 0
	if f:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	ara = list(map(int, input().strip().split()))
	cnt = 0
	for j in range(n - 1):
		if ara[j] == ara[j + 1]:
			cnt += 1
		else:
			cnt = 0
			break
	if cnt == 0:
		print(1)
	else:
		print(n)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	for i in range(0, n):
		if a[i] not in s:
			s.add(a[i])
	if len(s) == 1:
		print(n)
	else:
		print(1)
	t = t - 1


for case in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	flag = False
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			flag = True
	if flag:
		print(1)
	else:
		print(n)


for i in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(len(l))
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	integers = set(map(int, input().split()))
	if len(integers) == 1:
		print(n)
	else:
		print(1)


n = int(input())
for i in range(n):
	t = int(input())
	arr = [int(item) for item in input().split()]
	w = arr[0]
	count = 0
	for i in range(t):
		if arr[i] == w:
			count = count + 1
	if count == t:
		print(t)
	else:
		print(1)


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	ans = n
	for x in a:
		if x != a[0]:
			ans = 1
	print(ans)
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = [i for i in input().split()]
	c = 1
	d = {}
	a = len(s)
	for i in s:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in d:
		if d[i] == len(s):
			c = 0
	if c:
		print(1)
	else:
		print(len(s))


t = int(input())
for i in range(t):
	n = int(input())
	array = [int(j) for j in input().split()]
	if len(set(array)) == 1:
		print(len(array))
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	c = a.count(m)
	if c == n:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	flag = False
	for i in range(1, n):
		if a[i] != a[i - 1]:
			flag = True
			break
	if flag:
		print(1)
	else:
		print(n)


t = int(input())
for _ in range(t):
	n = int(input())
	a = set(map(int, input().split()))
	print([1, n][len(a) == 1])


import sys
import getpass
if getpass.getuser() == 'Morshed':
	sys.stdin = open('in.txt', 'r')
	sys.stdout = open('out.txt', 'w')
t = int(input())
while t > 0:
	n = int(input())
	ara = list(map(int, input().split()))
	if ara.count(ara[0]) == n:
		print(n)
	else:
		print(1)
	t -= 1


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	if len(c) > 1:
		print(1)
	else:
		print(n)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))[:n]
	c = 0
	for j in range(1, n):
		if s[j - 1] != s[j]:
			c += 1
	if c == 0:
		print(n)
	else:
		print('1')


t = int(input())
while t > 0:
	t -= 1
	input()
	arr = input().strip().split(' ')
	comp = arr[0]
	done = False
	for ele in arr:
		if ele != comp:
			print(1)
			done = True
			break
	if not done:
		print(len(arr))


T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	if min(A) == max(A):
		print(N)
	else:
		print(1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if min(l) == max(l):
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	num = [int(x) for x in input().split()]
	s = set(num)
	if len(s) == 1:
		print(n)
	else:
		print(1)


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = n
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			ans = 1
			break
	print(ans)


t = int(input())
for __ in range(t):
	n = int(input())
	arr = map(int, input().split())
	if len(set(arr)) == 1:
		print(n)
	else:
		print(1)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	n = int(data())
	a = mdata()
	s = set(a)
	if len(s) == 1:
		out(n)
	else:
		out(1)


def password(n, a):
	new = set(a)
	if len(new) == 1:
		return n
	else:
		return 1
n = int(input())
res = []
for i in range(n):
	p = int(input())
	a = list(map(int, input().split()))
	res.append(password(p, a))
for j in res:
	print(j)


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	A = Neo()
	if len(set(A)) == 1:
		print(n)
	else:
		print(1)


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = int(input().strip())
	a = [int(i) for i in input().rstrip().split()]
	allssame = a.count(a[0]) == n
	if allssame:
		print(n)
	else:
		print(1)

def main():
	tc = int(input().strip())
	for case in range(tc):
		solve()
main()


tc = int(input())
for i in range(0, tc):
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	mx = max(a)
	mn = min(a)
	if mx == mn:
		print(n)
	else:
		print(1)


def find_min_password_length(password):
	max_value = max(password)
	if password.count(max_value) < len(password):
		result = 1
	else:
		result = len(password)
	return result

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		password = tuple(map(int, input().split()))
		result = find_min_password_length(password)
		print(result)
main()


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	(idx, check) = (1, True)
	while idx < n:
		if arr[idx] != arr[0]:
			check = False
			break
		idx += 1
	if check:
		ans.append(n)
	else:
		ans.append(1)
for x in ans:
	print(x)


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	a = a.strip()
	a = a.split(' ')
	a = list(map(int, a))
	x = a.count(a[0])
	if x == len(a):
		print(n)
	elif x < len(a):
		print(1)


def fun(l):
	a = [i == l[0] for i in l]
	for i in a:
		if i == False:
			print(1)
			return
	print(len(l))
T = int(input())
for _ in range(T):
	i = int(input())
	x = input().split(' ')
	x = list(map(int, x))
	fun(x)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	n = ii()
	a = li()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	k = list(map(int, input().split()))
	same = k[0]
	bool = False
	for i in k:
		if i != same:
			bool = True
	if bool:
		print(1)
	else:
		print(n)


query = int(input())
for i in range(query):
	size = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr[0] == arr[size - 1]:
		print(size)
	else:
		print(1)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(lst):
	console('----- solving ------')
	if len(set(lst)) == 1:
		return len(lst)
	return 1

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	_ = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	print(res)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 0
	ok = False
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			ok = True
	if ok:
		print(1)
	else:
		print(n)


def all_same(a):
	return all([x == a[0] for x in a])
for _ in range(int(input())):
	N = int(input())
	array = [int(x) for x in input().split()]
	if all_same(array):
		print(N)
	else:
		print(1)


import math
t = int(input())
while t != 0:
	b = False
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(1, n, 1):
		if a[i] != a[0]:
			b = True
	if b:
		print(1)
	else:
		print(n)
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	if len(set(A)) == 1:
		print(len(A))
	else:
		print(1)


T = int(input())
for _ in range(T):
	N = int(input())
	arr = [int(x) for x in input().split()]
	p = set()
	for el in arr:
		p.add(el)
	if len(p) > 1:
		print(1)
	else:
		print(len(arr))


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	a.sort()
	if a[0] == a[n - 1]:
		print(n)
	else:
		print(1)


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if all((x == a[0] for x in a)):
		print(n)
	else:
		print(1)


a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	if z.count(z[0]) == len(z):
		print(len(z))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	d = {}
	if len(set(a)) > 1:
		print(1)
	else:
		print(n)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):
	if len(set(A)) == 1:
		return N
	return 1
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return list(map(int, sys.stdin.readline().split()))

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	print(1 if len(set(a)) != 1 else n)


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	if li[0] == li[n - 1]:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	if len(d) == 1:
		print(*d.values())
	else:
		print(1)


import sys
MOD = 10 ** 9 + 7

def power(a, b):
	if b == 0:
		return 1
	if b == 1:
		return a % MOD
	if b % 2 == 1:
		return power(a, b - 1) * a % MOD
	x = power(a, b / 2)
	return x * x % MOD
t = int(input())
while t > 0:
	n = int(input())
	arr = [int(x) for x in input().split()]
	d = len(list(set(arr)))
	if d == 1:
		print(n)
	else:
		print(1)
	t -= 1


for _ in range(int(input())):
	N = int(input())
	print(1 if len(set(input().split())) != 1 else N)


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7

def solve():
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	cnt = 0
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	for i in d:
		cnt += 1
	if cnt == 1:
		print(n)
	else:
		print('1')
t = 1
t = int(stdin.readline())
for _ in range(t):
	solve()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	temp = a[0]
	beq = True
	for i in a:
		if temp != i:
			beq = False
	if beq:
		print(n)
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = set()
	for i in a:
		b.add(i)
	if len(b) > 1:
		print(1)
	else:
		print(len(a))


T = int(input())
for case in range(T):
	i = int(input())
	ls = [int(x) for x in input().split()]
	s = set(ls)
	if len(s) == 1:
		print(len(ls))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	set1 = set(lst)
	if len(set1) == 1:
		print(n)
	else:
		print(1)


t = int(input(''))
for i in range(0, t):
	n = int(input(''))
	l = list(map(int, input('').strip().split()))
	if l.count(l[0]) == n:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = False
	m = max(a)
	for j in a:
		if j != m:
			f = True
			break
	if f:
		print(1)
	else:
		print(n)


from sys import stdin

def arr_sum(arr):
	if len(set(arr)) == 1:
		print(len(arr))
	else:
		print(1)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, stdin.readline().strip().split()))
	arr_sum(arr)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')
from collections import Counter

def solve(n, a):
	c = Counter(a)
	if len(c) == 1:
		return n
	return 1

def main():
	for _ in range(ri()):
		n = ri()
		a = ria()
		wi(solve(n, a))
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = getInts()
	return 1 if len(set(A)) > 1 else N
for _ in range(getInt()):
	print(solve())


from sys import stdin
input = stdin.readline
import math
lines = int(input())
for i in range(lines):
	length = int(input())
	values = list(map(int, input().split()))
	totalLength = 1
	if values.count(values[0]) == length:
		print(length)
	else:
		print(totalLength)


TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	cnt = 1
	val = A[0]
	for i in range(1, N):
		if val == A[i]:
			cnt += 1
	if cnt == N:
		print(N)
	else:
		print(1)


from math import *
t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	cnt = a.count(a[0])
	if n == cnt:
		print(cnt)
	else:
		print(1)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ch = 0
	for i in range(n):
		if a[i] == a[0]:
			ch += 1
	if ch == n:
		print(n)
	else:
		print(1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(len(l))
	else:
		print(1)


for test in range(0, int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if len(set(arr)) == 1:
		print(n)
	else:
		print(1)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, inf, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		a = inlist()
		if a.count(a[0]) == n:
			print(n)
		else:
			print(1)
main()


for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	print((1, len(a))[len({*a}) < 2])


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from time import clock
a = clock()
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(arr, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if arr[mid] == val:
			return mid
		elif arr[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, arr):
	for i in range(1, n):
		arr[i] += arr[i - 1]
	return arr

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
for _ in range(ii1()):
	n = ii1()
	arr = iia()
	flag = True
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			flag = False
			break
	if flag:
		print(n)
	else:
		print(1)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	if a.count(a[0]) == len(a):
		print(len(a))
	else:
		print(1)
for i in range(mint()):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if min(a) == max(a):
		print(len(a))
	else:
		print(1)


def string_to_list(s, char):
	collector = ''
	output_list = []
	for i in range(len(s)):
		if s[i] != char:
			collector += s[i]
			if i == len(s) - 1:
				output_list.append(int(collector))
		else:
			output_list.append(int(collector))
			collector = ''
	return output_list

def list_to_string(l, char):
	output_string = ''
	for i in range(len(l) - 1):
		output_string += str(l[i]) + char
	output_string += str(l[-1])
	return output_string

def quick_sort(l):

	def partition(l, start, end):
		pivot = l[end]
		i = start
		for j in range(start, end):
			if l[j] <= pivot:
				(l[j], l[i]) = (l[i], l[j])
				i += 1
		(l[end], l[i]) = (l[i], l[end])
		return i

	def recutrsion_part(l, start, end):
		if len(l) < 2:
			return l
		elif not start >= end:
			p = partition(l, start, end)
			recutrsion_part(l, start, p - 1)
			recutrsion_part(l, p + 1, end)
	recutrsion_part(l, 0, len(l) - 1)
	return l

def mergesort(l):

	def merge(l_1, l_2):
		output_list = []
		(i, j) = (0, 0)
		while i < len(l_1) and j < len(l_2):
			if l_1[i] < l_2[j]:
				output_list.append(l_1[i])
				i += 1
			else:
				output_list.append(l_2[j])
				j += 1
		if j == len(l_2):
			output_list += l_1[i:]
		else:
			output_list.append(l_2[j:])
		return output_list

	def sorty(l):
		if len(l) < 2:
			return l
		else:
			mid = len(l) // 2
			left = sorty(l[:mid])
			rit = sorty(l[mid:])
			return merge(left, rit)
	return sorty(l)

def minimum(l):
	minim = l[0]
	for i in l:
		if minim > i:
			minim = i
	return minim

def maximum(l):
	maxim = l[0]
	for i in l:
		if maxim < i:
			maxim = i
	return maxim

def list_reverse(l):

	def recursion(l, start, end):
		if start >= end:
			return l
		else:
			(l[start], l[end]) = (l[end], l[start])
			return recursion(l, start + 1, end - 1)
	return recursion(l, 0, len(l) - 1)

def max_min(x, y):
	if x > y:
		return (y, x)
	return (x, y)

def are_elements_equal(l):
	intermediate = l[0]
	for i in l:
		if intermediate != i:
			return False
		intermediate = i
	return True

def recursion_function(l):
	if are_elements_equal(l):
		return len(l)
	else:
		return 1

def main_function():
	test_cases = range(int(input()))
	output_list = []
	for test_case in test_cases:
		n = int(input())
		l = string_to_list(input(), ' ')
		x = recursion_function(l)
		output_list.append(x)
	return list_to_string(output_list, '\n')
print(main_function())


def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		if arr.count(arr[0]) == n:
			ans.append(str(n))
		else:
			ans.append('1')
	print('\n'.join(ans))
main()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	le = min(l)
	if m == le:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	x = int(input())
	tt = [*map(int, input().split())]
	if len(set(tt)) == 1:
		print(x)
	else:
		print(1)


import sys
input = sys.stdin.readline
import time
start_time = time.time()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
while t > 0:
	t -= 1
	n = inp()
	a = inlt()
	i = 0
	k = 0
	for j in range(int(n)):
		if n == 1:
			break
		k = 0
		while True:
			if i + 1 >= n or n == 1:
				break
			if a[i] != a[i + 1]:
				a[i] = a[i] + a[i + 1]
				n -= 1
			else:
				k = k + 1
				i += 1
		if k == n:
			break
		i -= 1
		while True:
			if i >= 0 or n == 1:
				break
			if a[i] != a[i + 1]:
				a[i] = a[i] + a[i + 1]
				a.pop(i + 1)
				n -= 1
			i -= 1
	print(n)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	for i in range(len(lst) - 1):
		if lst[i] != lst[i + 1]:
			print('1')
			break
	else:
		print(n)


import sys
t = int(input())
i = 0
for line in sys.stdin:
	if i == 0:
		n = int(line)
	else:
		a = [int(x) for x in line.split()]
		maxi = max(a)
		if a.count(maxi) < n:
			print(1)
		else:
			print(n)
	i = 1 - i


t = int(input())
for i in range(t):
	n = int(input())
	ar1 = [int(i) for i in input().split()]
	ele = ar1[0]
	lenar1 = len(ar1)
	if ar1.count(ele) == lenar1:
		print(lenar1)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	numbers = list(map(int, input().split()))
	status = True
	for i in range(n - 1):
		if numbers[i] != numbers[i + 1]:
			status = False
			break
	if status:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	c = a.count(m)
	i = a.index(m)
	if i != n - 1:
		if a[i - 1] == a[i + 1] and a[i - 1] == a[i]:
			if c < n:
				print('1')
			else:
				print(n)
		else:
			print('1')
	elif a[i - 1] != a[i]:
		print('1')
	else:
		print(n)


q = int(input())
for _ in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	import collections
	c = collections.Counter(dat)
	if len(list(c.keys())) == 1:
		print(n)
	else:
		print(1)


a = int(input())
i = 0
while i < a:
	b = int(input())
	s = 0
	m = 0
	c = input().split(' ')
	f = c[0]
	while s < b:
		if f == c[s]:
			m = m + 1
		s = s + 1
	if m == b:
		print(b)
	else:
		print(1)
	i = i + 1


t = int(input())
for j in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	for i in range(len(l) - 1):
		if l[i] == l[i - 1]:
			c = c + 1
	if c == n - 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	if ar[0] == ar[-1]:
		print(n)
	else:
		print(1)


import sys
import heapq
import math
from collections import deque
from collections import defaultdict
from collections import Counter
modH = int(10 ** 9) + 7
I = lambda : list(map(int, input().split(' ')))

def PRINT(lst, sep=' '):
	print(sep.join(map(str, lst)))
for _ in range(int(input())):
	n = int(input())
	lst = I()
	mm = max(lst)
	if sum([1 if a == mm else 0 for a in lst]) == n:
		print(n)
	else:
		print(1)


n = int(input())
for i in range(n):
	s = int(input())
	r = [int(x) for x in input().split()]
	a = max(r)
	b = min(r)
	if a == b:
		print(s)
	else:
		print(1)


(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	if len(set(X)) == 1:
		print(len(X))
	else:
		print(1)


def solution(arr):
	s = set(arr)
	if len(s) == 1:
		return len(arr)
	return 1
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(solution(arr))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	for j in range(n - 1):
		if l[j] != l[j + 1]:
			print('1')
			break
	else:
		print(n)


cases = int(input())
for case in range(0, cases):
	n = int(input())
	arr = list(map(int, input().split()))
	check = True
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			check = False
			break
	if check:
		print(len(arr))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	possible = False
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			possible = True
			break
	if possible == True:
		print(1)
	else:
		print(n)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	q = int(input())
	w = list(map(int, input().split()))
	if max(w) == min(w):
		print(q)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	A = input().split()
	a = list(map(int, A))
	if n == 1:
		print(1)
	else:
		for i in range(n):
			if a[i] == a[i + 1]:
				s = a.count(a[i])
				if s == n:
					print(n)
					break
				else:
					print(1)
					break
			else:
				print(1)
				break


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	if len(set(l)) > 1:
		print(1)
	else:
		print(n)


import sys
pprint = lambda s: print(' '.join(map(lambda x: str(x), s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


k = int(input())
lis = []
for i in range(k):
	u = int(input())
	if len(set(input().split())) == 1:
		lis.append(u)
	else:
		lis.append(1)
for i in lis:
	print(i)


n = int(input())
for i in range(n):
	x = int(input())
	a = set(map(int, input().split()))
	if len(a) == 1:
		print(x)
	else:
		print('1')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	c = 0
	for z in range(n):
		if a[z] not in ans:
			ans.append(a[z])
		if len(ans) > 1:
			c = 1
			break
	if c:
		print('1')
	else:
		print(n)


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = stdin.readline()
	ar = list(map(int, stdin.readline().split()))
	if max(ar) != min(ar):
		print(1)
	else:
		print(len(ar))


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	if l.count(l[0]) == n:
		print(n)
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == a[n - 1]:
		print(n)
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	c = 1
	for i in range(n - 1):
		if x[i] == x[i + 1]:
			c = c + 1
	if c == n:
		print(c)
	else:
		print(1)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	b = set(a)
	if len(b) == 1:
		print(n)
	else:
		print(1)


for _ in [0] * int(input()):
	(a, b) = (input(), list(map(int, input().split())))
	print(a if min(b) == max(b) else '1')


T = int(input())
for t in range(T):
	n = int(input())
	p = list(map(int, input().split()))
	ans = 1
	if p.count(p[0]) == n:
		ans = n
	print(ans)


t = int(input())
for x in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = 0
	for x in range(len(arr) - 1):
		if arr[x] != arr[x + 1]:
			flag = 1
	if flag == 1:
		print(1)
	else:
		print(n)


for _ in ' ' * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
	elif len(set(a)) == 1:
		print(n)
	else:
		print(1)


case = int(input())
for caseNum in range(0, case):
	n = int(input())
	numList = [int(x) for x in input().split()]
	if max(numList) != min(numList):
		print(1)
	else:
		print(n)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	n = stdint()
	arr = list(stdarr())
	if len(set(arr)) == 1:
		print(n)
	else:
		print(1)


t = int(input())

def check(a):
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			return False
	return True
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if check(a):
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if max(a) == min(a):
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if arr.count(arr[0]) != len(arr):
		print('1')
	else:
		print(len(arr))


for u in range(int(input())):
	n = int(input())
	x = [int(w) for w in input().split()]
	if len(set(x)) == 1:
		print(len(x))
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print('1')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		rr.append(IF(len(set(a)) == 1, n, 1))
	return JA(rr, '\n')
print(main())


for _ in range(0, int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	if len(set(b)) == 1:
		print(a)
	else:
		print(1)


def is_uniform(array):
	if any([value != array[0] for value in array[1:]]):
		return 1
	else:
		return len(array)
total = int(input())
for index in range(2 * total):
	line = input()
	if index % 2 == 0:
		continue
	array = [int(x) for x in line.split(' ')]
	shortest = is_uniform(array)
	print(shortest)


import sys, os
cases = int(sys.stdin.readline())
for x in range(cases):
	size = int(sys.stdin.readline()[:-1])
	arr = sys.stdin.readline()[:-1].split(' ')
	vals = set(arr)
	if size == 1 or len(vals) == 1:
		print(size)
	else:
		print(1)


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	if a[0] == a[n - 1]:
		print(n)
	else:
		print('1')
	t -= 1


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
mo = 1000000007
for _ in range(int(input())):
	n = inn()
	a = arr()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = read()
		if len(set(arr)) != 1:
			print(1)
		else:
			print(n)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	if a.count(mx) == n:
		print(n)
		continue
	(t, c) = (0, 1)
	for i in range(n):
		if a[i] == mx:
			c += 1
			if t == mx:
				c += 1
			else:
				c = 1
			try:
				if a[i - 1] != mx:
					c = 1
				if a[i + 1] != mx:
					c = 1
			except:
				pass
			t = 0
		else:
			t += a[i]
	if t != mx:
		c = 1
	print(c)


def solve(test):
	ans = 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == a[-1]:
		ans = n
	print(ans)
t = int(input())
for _ in range(t):
	solve(_ + 1)


import math
import bisect
import copy
import time
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


from __future__ import division, print_function
import os, sys
import math
import collections
from itertools import permutations
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def primeFactors(n):
	j = []
	while n % 2 == 0:
		j.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			j.append(int(n))
			n = n / i
	if n > 2:
		j.append(int(n))
	return j

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def question(a, n):
	j = a
	for i in range(n):
		if a[i] == '1':
			j[i] = '0'
		else:
			j[i] = '1'
	j[0, n - 1].reverse()
	return j

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = []
		if len(set(a)) == 1:
			print(n)
		else:
			print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def solve(nums, n):
	if n == 0:
		return 0
	if len(set(nums)) == 1:
		return n
	return 1
for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	print(solve(nums, n))


def main():
	n = int(input())
	for i in range(n):
		solve()

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print(n)
	else:
		print(1)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a == [a[0]] * n:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	flag = 0
	for x in range(1, n):
		if arr[x - 1] != arr[x]:
			print('1')
			flag = 1
			break
	if flag == 0:
		print(len(arr))


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	x = all((element == a[0] for element in a))
	if x:
		print(n)
	else:
		print(1)


import math
import sys
import itertools
import random
import bisect
import heapq
import collections

def lcm(x, y):
	return x * y // math.gcd(x, y)

def hcf(x, y):
	return math.gcd(x, y)

def primes(n):
	prime = [True for _ in range(0, n + 1)]
	res = []
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[p] = False
		p += 1
	for i in range(0, n + 1):
		if prime[i] == True:
			res.append(i)
	return res

def primeFactors(n):
	res = []
	while n % 2 == 0:
		res.append(2)
		n //= 2
	for i in range(3, math.sqrt(n) + 1, 2):
		while n % i == 0:
			res.append(i)
			n //= i
	if n > 2:
		res.append(n)
	return res
for _ in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	if len(set(l)) == 1:
		print(len(l))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	(*arr,) = map(int, input().split())
	if arr.count(arr[0]) == len(arr):
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = True
	for i in range(1, n):
		if arr[i - 1] != arr[i]:
			flag = False
			break
	if flag:
		print(n)
	else:
		print(1)


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	k = max(lst)
	lst2 = [i for i in lst if i != k]
	if len(lst2):
		print(1)
	else:
		print(n)
for i in range(int(input())):
	solve()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == l[-1]:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')[:n]]
	if min(a) == max(a):
		print(n)
	else:
		print(1)


tests = int(input())
for test in range(tests):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			print(1)
			break
	else:
		print(n)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	n = sInt()
	a = lInt()
	if a.count(a[0]) == n:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(a[0]) == n:
		print(n)
		continue
	print(1)


kase = int(input().strip())
while kase > 0:
	kase = kase - 1
	n = int(input().strip())
	a = [int(_) for _ in input().strip().split()]
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input().split()
		if n == 1:
			print(1)
		else:
			flag = 1
			a = s[0]
			for i in s:
				if i != a:
					flag = 0
					break
			if flag:
				print(n)
			else:
				print(1)
main()


import sys, math as mt
import heapq as hp
import collections as cc
import bisect as bi
import math as mt
import itertools as it
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


n = int(input())
for i in range(n):
	noe = int(input())
	li = list(map(int, input().split(' ')))
	base = li[0]
	count = 0
	for i in range(len(li)):
		if li[i] == base:
			count += 1
	if count == len(li):
		print(len(li))
	else:
		print(1)


t = int(input())
while t > 0:
	n = int(input())
	lis = list(map(int, input().split()))
	s = set(lis)
	if len(s) is not 1:
		print(1)
	else:
		print(n)
	t -= 1


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = set()
	for x in a:
		s.add(x)
	if len(s) == 1:
		print(n)
	else:
		print(1)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum
from math import *
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	if n == 1:
		print(1)
	else:
		f1 = 0
		for i in range(1, n):
			if lis[0] != lis[i]:
				f1 = 1
				break
		if f1 == 1:
			print(1)
		else:
			print(n)


from bisect import bisect_left, bisect_right
from itertools import combinations
from itertools import permutations
from bisect import bisect_left
from math import ceil
from math import radians
from heapq import heapify, heappush, heappop
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0 and i % 2 == 1:
			s.add(i)
			n = n // i
	if n > 2 and n % 2 == 1:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count

def cou(n):
	c = 0
	while n > 1:
		c += 1
		n //= 2
	return c

def sortsec(l):
	return sorted(l, key=lambda x: x[1])

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def subarray(A):
	r = set()
	p = {0}
	for x in A:
		p = {x | y for y in p} | {x}
		r |= p
	return len(r)
for _ in range(ii()):
	n = ii()
	l = sorted(li1())
	if l[0] == l[-1]:
		print(len(l))
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()][:n]
	s = a.count(a[0])
	if s == n:
		print(n)
	else:
		print(1)


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	v = len(set(A))
	if v == 1:
		print(len(A))
	else:
		print(1)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


x = int(input())
for i in range(0, x):
	n = int(input())
	m = list(map(int, input().split()))[:n]
	if len(set(m)) == 1:
		print(len(m))
	else:
		print(1)


from sys import exit, stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
(T,) = rl()
for _ in range(T):
	(n,) = rl()
	a = rl()
	if min(a) == max(a):
		print(n)
	else:
		print(1)


minimal = 99999999999

def found(mas, minimal):
	Cmas = []
	flag = True
	if len(mas) == 1:
		return 1
	else:
		for j in range(len(mas)):
			for k in range(len(mas)):
				if j != k and j + 1 != k:
					Cmas.append(mas[k])
				elif flag:
					Cmas.append(mas[j] + mas[j + 1])
					flag = False
			c = found(Cmas, minimal)
			if minimal > c:
				minimal = c
			elif minimal == c:
				minimal
			Cmas.clear()
			return minimal
n = int(input())
answer = []
for i in range(n):
	k = int(input())
	mas = [int(j) for j in input().split()]
	flag = 0
	for j in mas:
		if j == mas[0]:
			flag += 1
	if flag == len(mas):
		answer.append(len(mas))
	else:
		answer.append(1)
for i in answer:
	print(i)


t = int(input())
tsum = 0
output = []
if t < 1 or t > 100:
	raise ValueError
for i in range(t):
	n = int(input())
	if n < 1 or n > 200000:
		raise ValueError
	tsum += n
	if tsum > 2000000:
		raise ValueError
	psort = []
	for j in input().split():
		if int(j) < 1 or int(j) > 10 ** 9:
			raise ValueError
		psort.append(int(j))
	k = 0
	l = 0
	for j in psort:
		if j == psort[0]:
			l += 1
		k += 1
	if k != n:
		raise ValueError
	if l == k:
		output.append(k)
	elif k == 0:
		output.append(0)
	else:
		output.append(1)
for i in output:
	print(i)


for _ in range(int(input())):
	(n, a) = (int(input()), input().split())
	for row in a:
		if a[0] != row:
			print(1)
			break
	else:
		print(n)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = set(a)
	c = list(b)
	for i in range(len(c)):
		if len(c) >= 2:
			print('1')
			break
	else:
		print(len(a))


t = int(input())
b = [0] * t
for i in range(t):
	n = int(input())
	a = [0] * n
	a = input().split()
	if len(set(a)) == 1 and len(a) > 1:
		b[i] = n
	else:
		b[i] = 1
for i in range(t):
	print(b[i])


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for j in range(len(l)):
		if l[j] in d:
			d[l[j]] += 1
		else:
			d[l[j]] = 1
	s = d.keys()
	if len(s) == 1:
		print(n)
	else:
		print(1)


for q in range(int(input())):
	n = int(input())
	print(1 if len(set(list(map(int, input().split())))) != 1 else n)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	for i in l:
		if i != l[0]:
			f = 1
			break
	if f == 0:
		print(n)
	else:
		print(1)
	t -= 1


t = int(input())
for ex in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	equal = True
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			equal = False
			break
	if equal:
		print(n)
	else:
		print(1)


try:
	for _ in range(int(input())):
		n = int(input())
		arr = [int(x) for x in input().split()]
		arr.sort()
		if arr[0] == arr[-1]:
			print(n)
		else:
			print('1')
except:
	pass


def cal(arr):
	b = set(arr)
	if len(b) == 1:
		return len(arr)
	else:
		return 1
for x in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(cal(a))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
	elif n == 2:
		if a[0] != a[1]:
			print(1)
		else:
			print(2)
	else:
		flag = 0
		for i in range(1, n):
			if a[i] != a[i - 1]:
				flag = 1
				break
		if flag == 1:
			print(1)
		else:
			print(n)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	if a[0] == a[n - 1]:
		print(n)
	else:
		print(1)


t = input()
t = int(t)
for i in range(t):
	n = input()
	n = int(n)
	arr = list(map(int, input().rstrip().split()))
	j = 0
	c = 1
	while j < len(arr) - 1:
		if arr[j] != arr[j + 1]:
			c = 0
		j = j + 1
	if c == 0:
		print(1)
	else:
		print(n)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == a[n - 1]:
		print(n)
	else:
		print(1)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 10 ** 9 + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def a():
	n = int(input())
	arr = set(map(int, input().split()))
	if len(arr) > 1:
		print(1)
	else:
		print(n)

def b():
	(n, k) = vars()
	arr = array()
	k = 1 if k % 2 == 1 else 2
	while k:
		m = max(arr)
		for i in range(n):
			arr[i] = m - arr[i]
		k -= 1
	print(*arr)
t = 1
t = int(input())
for _ in range(t):
	a()


from collections import *
from sys import *
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	if len(s) == 1:
		stdout.write(str(n) + '\n')
	else:
		stdout.write('1\n')


def solve(n, a):
	if len(set(a)) == 1:
		return n
	return 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


for test in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if arr.count(arr[0]) == n:
		print(n)
	else:
		print(1)


from collections import defaultdict
import math

def number(a, n):
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			return 1
	return n
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(number(a, n))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	occ = Counter(arr)
	if len(occ) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	ai = list(map(int, input().split()))
	ans = n
	for i in range(1, n):
		if ai[i] != ai[i - 1]:
			ans = 1
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	if s.count(s[0]) < n:
		n = 1
	print(n)


from collections import Counter
t = int(input())
for i in range(t):
	x = int(input())
	ar = list(map(int, input().split()))
	d = Counter(ar)
	if len(d) == 1:
		print(x)
	else:
		print(1)


for t in range(int(input())):
	input()
	a = [int(e) for e in input().split()]
	if a.count(a[0]) == len(a):
		print(len(a))
	else:
		print(1)


t = int(input())
while t != 0:
	n = input()
	s = set((int(x) for x in input().split(' ')))
	if len(s) > 1:
		print(1)
	else:
		print(n)
	t -= 1


tests = int(input())
for _ in range(tests):
	_ = int(input())
	a = list(map(int, input().split()))
	unique = set(a)
	if len(unique) == 1:
		print(len(a))
	else:
		print(1)


class Main:

	def main(self):
		t = int(input())
		for t1 in range(0, t):
			n = int(input())
			a = list(map(int, input().split()))
			if all(map(lambda x: x == a[0], a)):
				print(n)
			else:
				print(1)
Main().main()


from typing import List

def password(n: int, arr: List[int]):
	if all((number == arr[0] for number in arr)):
		return n
	else:
		return 1
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	print(password(n, arr))
	t -= 1


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	ans = ''
	for _ in range(ii()):
		n = ii()
		arr = li()
		sett = set()
		for i in arr:
			sett.add(i)
		if len(sett) == 1:
			ans += str(n) + '\n'
		else:
			ans += '1\n'
	print(ans)
main()


T = int(input())
while T:
	n = int(input())
	A = list(map(int, input().split()))
	if len(set(A)) == 1:
		print(len(A))
	else:
		print(1)
	T = T - 1


def inplst():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	l = inplst()
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	print([1, n][a[0] == a[n - 1]])


def mag():
	N = int(input())
	for i in range(N):
		a = int(input())
		b = input().strip().split()
		c = 1
		for j in range(1, a):
			if b[j] == b[j - 1]:
				c += 1
		if c == a:
			print(c)
		else:
			print(1)
mag()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[0]
	am = True
	for i in range(1, n):
		if a[i] != b:
			am = False
			break
	if am:
		print(n)
	else:
		print(1)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ans = N
	for i in range(1, N):
		if A[i] != A[i - 1]:
			ans = 1
			break
	print(ans)


for x in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if min(l) == max(l):
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	k = set(s)
	if len(list(k)) == 1:
		print(n)
	else:
		print(1)


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	n = r()
	a = rl()
	ans = False
	for i in a:
		if i != a[0]:
			ans = True
			break
	if ans:
		print(1)
	else:
		print(n)


t = int(input())
for it in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	if len(set(arr)) == 1:
		print(n)
	else:
		print(1)
for _ in range(int(input())):
	solve()


n = int(input())
for i in range(n):
	k = int(input())
	s = set(map(int, input().split()))
	if len(s) == 1:
		print(k)
	else:
		print(1)


n = int(input())
for _ in range(n):
	n1 = int(input())
	mm = list(map(int, input().split()))
	if len(set(mm)) == 1:
		print(len(mm))
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	if len(set(li)) > 1:
		print(1)
	else:
		print(len(li))


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	arr = list(map(int, stdin.readline().strip().split(' ')))
	if len(set(arr)) == 1:
		stdout.write(str(len(arr)) + '\n')
	else:
		stdout.write(str(1) + '\n')


from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print(n)
	else:
		print('1')


t = int(input())
for q in range(t):
	n = int(input())
	arr = input().split()
	new = [int(arr[i]) for i in range(n)]
	x = 0
	for i in range(n - 1):
		if new[i] != new[i + 1]:
			x = 1
	if x == 1:
		print(1)
	else:
		print(n)


n = int(input())
for i in range(0, n):
	n1 = int(input())
	a = list(map(int, input().split()))
	if n1 == 1:
		print(1)
		continue
	k = sorted(a)
	if k[0] == k[n1 - 1]:
		print(n1)
	else:
		print(1)


def main():
	import sys

	def get_multiple_ints():
		return list(map(int, sys.stdin.readline().strip().split()))

	def get_single_int():
		return list(map(int, sys.stdin.readline().strip().split()))[0]
	for _ in range(get_single_int()):
		length = get_single_int()
		passwords = get_multiple_ints()
		passwords.sort()
		if passwords[0] == passwords[-1]:
			print(length)
		else:
			print(1)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	i = -1
	k = len(set(a))
	if n == 1:
		print('1')
	elif len(set(a)) == 1:
		print(len(a))
	else:
		print('1')


import sys
import math
from collections import Counter, defaultdict
input = sys.stdin.readline
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	n = IN()
	a = LI()
	if a.count(a[0]) == n:
		print(n)
	else:
		print(1)
for _ in range(IN()):
	case()


t = int(input())
anss = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split(sep=' ')))
	d = set(l)
	if len(d) == 1:
		anss.append(len(l))
	else:
		anss.append(1)
for ans in anss:
	print(ans)


import sys

def main():
	inp = sys.stdin.read().strip().split('\n')[2::2]
	out = []
	for i in inp:
		t = i.split()
		out.append(len(set(t)) > 1 and 1 or len(t))
	return out
print(*main(), sep='\n')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 5
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	if a.count(a[0]) == n:
		print(n)
	else:
		print(1)


def password(a, size):
	if a.count(max(a)) == size:
		return size
	return 1
tests = int(input())
for i in range(tests):
	size = int(input())
	slides = list(map(int, input().split()))
	print(password(slides, size))


def solve(n, A):
	A.sort()
	if A[0] == A[n - 1]:
		return n
	else:
		return 1
t = int(input())
while t:
	res = []
	n = int(input())
	in_ = map(int, input().split(' '))
	for x in in_:
		res.append(int(x))
	print(solve(n, res))
	t -= 1


from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = len(Counter(l).keys())
	if a == 1:
		print(len(l))
	else:
		print(1)


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	equal = True
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			equal = False
			break
	if equal is True:
		print(n)
	else:
		print(1)
	T -= 1


t = int(input())
myList = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	i = 1
	while i < n:
		if a[i] != a[i - 1]:
			break
		i += 1
	if i == n:
		myList.append(n)
	else:
		myList.append(1)
for elem in myList:
	print(elem)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		f = True
		for j in range(1, len(a)):
			if a[j] != a[j - 1]:
				f = False
				break
		if f:
			print(n)
		else:
			print(1)
main()


N = int(input())
for _ in range(N):
	M = int(input())
	K = list(map(int, input().split()))
	if len(list(set(K))) == 1:
		print(len(K))
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(set((int(x) for x in input().split())))
	if len(a) == 1:
		print(n)
	else:
		print(1)


n = int(input())
res = []
for i in range(n):
	t = int(input())
	P = list(map(int, input().split()))
	if len(set(P)) != 1:
		res.append(1)
	else:
		res.append(t)
for k in res:
	print(k)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	val = a[0]
	count = 1
	for i in a[1:]:
		if val == i:
			count += 1
	if count == n:
		print(n)
	else:
		print(1)
	t -= 1


import sys
T = int(sys.stdin.readline())
for i in range(T):
	N = int(sys.stdin.readline())
	nums = list(map(int, sys.stdin.readline().split()))
	if len(set(nums)) == 1:
		print(len(nums))
	else:
		print(1)


from collections import Counter
t = int(input())
for _x in range(t):
	n = int(input())
	a = [int(item) for item in input().split()][:n]
	cnt = Counter(a).most_common()
	if cnt[0][1] == n:
		print(n)
	else:
		print(1)


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().strip().split()))
	if max(a) == min(a):
		print(n)
	else:
		print(1)


def solve(a, n):
	temp = a[0]
	count = arr.count(temp)
	if count == n:
		return n
	return 1
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr, n))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	n = intIn()
	a = listIn()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	if a == [a[0]] * n:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 1
	for j in range(1, n):
		if a[j] != a[j - 1]:
			break
		cnt += 1
	if cnt == n:
		print(n)
	else:
		print(1)


import sys
import math
from math import *
from collections import Counter, defaultdict

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	a = len(list(set(arr)))
	if a == 1:
		print(n)
	else:
		print(1)
for i in range(int(input())):
	main()


for t in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	if l1.count(l1[0]) == n:
		print(n)
	else:
		print(1)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		d = {}
		for i in a:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		if len(d) == 1:
			print(n)
		else:
			print(1)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = list(a)
	a.sort(reverse=True)
	sum = 0
	lst = []
	for i in range(n):
		if sum != a[i]:
			sum += a[i]
		else:
			lst.append(a[i])
	if sum in lst and len(set(lst)) == 1:
		print(len(lst) + 1)
	else:
		print(1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	for i in a:
		d[i] += 1
	if len(d) == 1:
		print(d[a[0]])
	else:
		print(1)


T = int(input())
for _ in range(T):
	input()
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(len(l))
	else:
		print(1)


def checker(n, lst):
	lst.sort()
	return n if lst[0] == lst[-1] else 1
for _ in range(int(input())):
	m = int(input())
	a = [int(i) for i in input().split()]
	print(checker(m, a))


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	n = II()
	li = L()
	s = set()
	for ele in li:
		s.add(ele)
	if len(s) == 1:
		P(n)
	else:
		P(1)
	return
t = II()
for i in range(t):
	solve()


from sys import stdin
for i in range(int(input())):
	n = int(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	l.sort()
	if l[0] == l[-1]:
		print(n)
	else:
		print(1)


for test in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split(' ')))
	l = sorted(l)
	i = len(l) - 1
	count = 0
	flag = 0
	while i >= 0:
		if l[i - 1] != l[-1]:
			if l[i] + l[i - 1] > l[-1]:
				print(1)
				flag = 1
				break
			else:
				l[i - 1] = l[i] + l[i - 1]
				i -= 1
				count += 1
		else:
			i -= 1
	if flag == 0:
		print(len(l) - count)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	found = False
	for i in a[1:]:
		if i != a[0]:
			found = True
	if found:
		print(1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	if len(set(lst)) == 1:
		print(n)
		continue
	else:
		print(1)


def solve(n, ar):
	s = set(ar)
	if len(s) == 1:
		print(n)
	else:
		print(1)
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	solve(n, ar)


t = int(input())
for _ in range(t):
	n = int(input())
	inp = [int(i) for i in input().split()]
	inp.sort()
	if inp[0] == inp[n - 1]:
		print(len(inp))
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	isAllSame = True
	for i in range(n):
		if i != 0 and a[i] != a[i - 1]:
			isAllSame = False
			break
	if isAllSame:
		print(n)
	else:
		print(1)


t = int(input())
while t:
	cnt = 0
	n = int(input())
	a = list(map(int, input().split(' ')))
	for i in range(1, len(a)):
		if a[i] != a[i - 1]:
			cnt = cnt + 1
	if cnt == 0:
		print(n)
	else:
		print(1)
	t = t - 1


import sys

class AOmkarAndPassword:

	def solve(self, tc=0):
		for _ in range(int(input())):
			n = int(input())
			a = [int(_) for _ in input().split()]
			if len(set(a)) == 1:
				print(len(a))
			else:
				print(1)
solver = AOmkarAndPassword()
input = sys.stdin.readline
solver.solve()


def password(arr, n):
	if n == 1:
		return 1
	elif len(set(arr)) == 1:
		return n
	else:
		return 1
		return password(arr, n - 1)
for _ in range(int(input())):
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	print(password(arr, n))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n == 1:
		print(1)
	elif min(a) == max(a):
		print(n)
	else:
		print(1)


import sys
input = sys.stdin.readline

def main(n, lst):
	if lst != [lst[0]] * n:
		return 1
	else:
		return n
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(main(n, lst))


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(a[0]) == n:
		print(n)
	else:
		print(1)


T = int(input())
for i in range(T):
	N = int(input())
	flag = 0
	A = list(map(int, input().split()))
	count = 0
	for i in range(N - 1):
		if A[i] != A[i + 1]:
			flag = 1
			break
		else:
			count += 1
	if flag == 1:
		print(1)
	else:
		print(N)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	if all((x == l[0] for x in l)):
		print(len(l))
	else:
		print(1)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	for i in a:
		d[i] = 1
	if len(d) > 1:
		print(1)
	else:
		print(n)


t = int(input())
res = []
for row in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	current = a[0]
	all_the_same = True
	for ai in a:
		if ai != current:
			all_the_same = False
			break
	if all_the_same:
		print(n)
	else:
		print(1)


a = int(input())
for i in range(a):
	sch = 0
	b = int(input())
	st = str(input()).split(' ')
	s = int(st[0])
	for j in range(b):
		if int(st[j]) != s:
			sch += 1
			break
	if sch != 0:
		print(1)
	else:
		print(b)


import sys, collections, math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	n = int(input())
	arr = get_array()
	cnt = 0
	if min(arr) == max(arr):
		print(n)
	else:
		print(1)


print('\n'.join([(lambda n, a: '1' if len(set(a)) > 1 else str(len(a)))(input(), [int(x) for x in input().split()]) for i in range(int(input()))]))


t = int(input())
for _ in range(t):
	n = int(input())
	password = [int(i) for i in input().split()]
	first = password[0]
	for e in password:
		if e != first:
			print(1)
			break
	else:
		print(n)


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list((int(n) for n in input().split()))
	s = list1[:]
	if len(set(s)) == 1:
		print(len(list1))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(n if all((ele == a[0] for ele in a)) == True else 1)


t = int(input())
my_lis = []
for j in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	size = len(l)
	detected = False
	i = 0
	while i < size - 1 and detected == False:
		detected = l[i] != l[i + 1]
		i += 1
	if detected == False:
		my_lis.append(size)
	else:
		my_lis.append(1)
for el in my_lis:
	print(el)


from sys import stdin
input = lambda : stdin.readline().strip()
from collections import deque as d
for _ in range(int(input())):
	n = int(input())
	b = []
	a = d(map(int, input().split()))
	i = 0
	if a.count(a[0]) == len(a):
		print(len(a))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = [int(d) for d in input().split()]
	b = False
	m = max(arr)
	if arr.count(m) == n:
		print(n)
	else:
		print(1)


try:
	t = int(input())
	while t != 0:
		n = int(input())
		arr = list(map(int, input().split()))
		maxnum = max(arr)
		p = arr.count(maxnum)
		if p == n:
			print(n)
		else:
			print(1)
		t = t - 1
except EOFError:
	print(' ')


for i in range(int(input())):
	s = int(input())
	a = set(map(int, input().split()))
	if len(a) == 1:
		print(s)
	else:
		print(1)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def test():
	n = int(input())
	a = list(map(int, input().split()))
	return a.count(max(a)) if a.count(max(a)) == n else 1
t = int(input())
for _ in range(t):
	print(test())


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	if all(map(lambda x: x == a[0], a)):
		print(n)
	else:
		print(1)
t = int(input())
for _ in range(t):
	solve()


from sys import stdout, stdin
(_input, _print) = (stdin.readline, stdout.write)
(_len, _int, _range) = (len, int, range)

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		arr = [_int(i) for i in _input().split()]
		z = arr[0]
		for i in arr:
			if i != z:
				print(1)
				break
		else:
			print(_len(arr))
solution()


aea = int(input())
for time in range(aea):
	l = int(input())
	op = []
	rt = input().split()
	op = rt
	for er in range(l):
		op[er] = int(op[er])
	ap = op[0]
	if op.count(ap) == l:
		print(l)
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	li = [int(x) for x in input().split()]
	count = 1
	temp = 0
	for i in range(1, n):
		if li[i] == li[i - 1]:
			count += 1
		else:
			break
	if count == n:
		print(n)
	else:
		print(1)


for ctr in range(int(input())):
	lnegth_of_password = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	print(1 if a[0] != a[-1] else lnegth_of_password)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	if l.count(l[0]) == n:
		print(n)
	else:
		print(1)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(input())):
	n = int(input())
	arr = l()
	if len(set(arr)) == 1:
		out(n)
		continue
	out(1)


import sys
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	if len(list(set(l))) == 1:
		print(len(l))
	else:
		print(1)


import math
T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, list(input().split())))
	d = False
	if n == a.count(a[0]):
		print(n)
	else:
		print(1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
from bisect import bisect_left
from collections import defaultdict

def solve():
	t = int(input())
	for _ in range(t):
		n = int(input())
		ar = lis()
		if ar.count(ar[0]) == n:
			print(n)
		else:
			print(1)
solve()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(i) for i in input().split()]
	if len(list(set(l1))) == 1:
		print(len(l1))
	else:
		print(1)


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict, Counter

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo
	return -1

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None
import os
import sys
from io import BytesIO, IOBase

def DecimalToBinary(n):

	def helper(n):
		if n == 0:
			return ''
		else:
			if n % 2 == 1:
				binaryDigit = '1'
			else:
				binaryDigit = '0'
			return helper(n // 2) + binaryDigit
	if n == 0:
		result = '0'
	else:
		result = helper(n)
	return result

def p(board):
	for i in range(8):
		s = ''
		for j in range(8):
			s += board[i][j]
		print(s)

def binaryToDecimal(n):
	return int(n, 2)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def solve(a, b):
	x = DecimalToBinary(a)
	y = DecimalToBinary(b)
	z = x + y
	l = y + x
	r = binaryToDecimal(z) - binaryToDecimal(l)
	return r

def mostFrequent(arr, n):
	arr.sort()
	max_count = 1
	res = arr[0]
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			if curr_count > max_count:
				max_count = curr_count
				res = arr[i - 1]
			curr_count = 1
	if curr_count > max_count:
		max_count = curr_count
		res = arr[n - 1]
	return res

def sub_lists(list1):
	sublist = [[]]
	for i in range(len(list1) + 1):
		for j in range(i + 1, len(list1) + 1):
			sub = list1[i:j]
			sublist.append(sub)
	return sublist

def check(s):
	n = len(s)
	if n == 1:
		return True
	return s == s[::-1]
for _ in range(inp()):
	n = inp()
	a = inlt()
	a = set(a)
	if len(a) == 1:
		print(n)
	else:
		print(1)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if min(a) == max(a):
		ans.append(len(a))
	else:
		ans.append(1)
for i in ans:
	print(i)


for _ in range(int(input())):
	m = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(m)
	else:
		print('1')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	lis = set(map(int, input().split()))
	if len(lis) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	if len(set(li)) == 1:
		print(n)
		continue
	print(1)


t = int(input())
while t > 0:
	n = int(input())
	arr = input().split()
	if len(set(arr)) > 1:
		print(1)
	else:
		print(len(arr))
	t -= 1


for _ in range(int(input())):
	N = int(input())
	List = [int(x) for x in input().split()]
	if List.count(List[0]) == N:
		print(N)
	else:
		print(1)


for s in [*open(0)][2::2]:
	s = s.split()
	print([1, len(s)][len({*s}) < 2])


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr[0] == arr[-1]:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	snum = sorted(num)
	if snum[0] == snum[-1]:
		print(n)
	else:
		print(1)


def sol(lis):
	lis.sort()
	if lis[0] == lis[-1]:
		print(len(lis))
		return
	print(1)
k = int(input())
for i in range(k):
	input()
	lis = list(map(int, input().split(' ')))
	sol(lis)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	M = len(set(L))
	if M == 1:
		print(n)
		continue
	print(1)


import math as mt

def tran(arr):
	if len(set(arr)) == 1:
		return len(arr)
	else:
		return 1
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	r = tran(arr)
	ans.append(r)
for i in ans:
	print(i)


n = int(input())
for i in range(n):
	m = int(input())
	s = input().split(' ')
	a = []
	for j in range(m):
		a.append(int(s[j]))
	f = False
	for j in range(m - 1):
		if a[j] != a[j + 1]:
			f = True
	if f:
		print(1)
	else:
		print(m)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	a = li()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)
for _ in range(I()):
	solve()


from sys import stdin, stdout
import bisect
import math
from collections import deque
mod = 10 ** 9 + 7

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def DFS(dictionary, vertex, visited):
	visited[vertex] = True
	stack = [vertex]
	print(vertex)
	while stack:
		a = stack.pop()
		for i in dictionary[a]:
			if not visited[i]:
				print(i)
				visited[i] = True
				stack.append(i)

def BFS(dictionary, vertex, visited):
	visited[vertex] = True
	q = deque()
	q.append(vertex)
	while q:
		a = q.popleft()
		for i in dictionary[a]:
			if not visited[i]:
				visited[i] = True
				q.append(i)
				print(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	a = set(l)
	if len(a) != 1:
		pr(1)
	else:
		pr(n)
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	k = max(arr)
	temp = True
	for i in range(n):
		if arr[i] != k:
			temp = False
			break
	if temp:
		print(n)
	else:
		print('1')


def nextInt():
	return int(input())

def intArr():
	arr = input().split(' ')
	return [int(x) for x in arr]
t = nextInt()
ans = []
for tt in range(t):
	length = nextInt()
	a = intArr()
	a.sort()
	dup = []
	if length == 2:
		if a[0] != a[1]:
			ans.append(1)
		else:
			ans.append(2)
	elif a[length - 1] == a[0]:
		ans.append(length)
	else:
		ans.append(1)
for x in ans:
	print(x)


from math import ceil
from collections import deque
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	n = iinput()
	a = get_list()
	s = set(a)
	if len(s) == 1:
		print(n)
	else:
		print(1)


t = int(input())

def fm(a):
	i = 0
	m = a[0]
	for j in range(len(a)):
		if a[j] > m:
			m = a[j]
			i = j
	return i
while t:
	t -= 1
	a = []
	n = int(input())
	bol = 0
	s = input().split()
	for i in s:
		a.append(int(i))
	mi = fm(a)
	if mi != 0:
		print(1)
		continue
	mi += 1
	while mi < len(a):
		if a[mi - 1] != a[mi]:
			bol = 1
		mi += 1
	if bol:
		print(1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	check = a[0]
	cnt = 0
	for i in a:
		if i == check:
			cnt += 1
	if cnt == n:
		print(n)
	else:
		print(1)


import sys
from collections import defaultdict, deque
import math
INF = float('inf')
MOD = 10 ** 9 + 7
read = lambda : [int(s) for s in sys.stdin.readline().split()]

def solve():
	(n,) = read()
	arr = read()
	s = set(arr)
	if len(s) == 1:
		print(n)
	else:
		print(1)
_ = 1
_ = int(input())
while _:
	solve()
	_ -= 1


import math
import sys
import bisect
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ch = 0
	for i in range(n - 1):
		if l[i] != l[i + 1]:
			ch = 1
	if ch == 0:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ans = n
	for i in range(1, len(ar)):
		if ar[i] != ar[i - 1]:
			ans = 1
			break
	print(ans)


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	n = iinput()
	a = rlinput()
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


from collections import Counter
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a = Counter(a)
	if len(a) == 1:
		print(n)
	else:
		print(1)


def solve(l, n):
	f = 0
	for i in range(n - 1):
		if l[i] != l[i + 1]:
			f = 1
			break
	if f == 1:
		print(1)
	else:
		print(n)
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	solve(l, n)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	x = 0
	for d in range(len(s) - 1):
		if s[d] != s[d + 1]:
			x += 1
	if x > 0:
		print(1)
	else:
		print(n)


def solution(p):
	big = max(p)
	if all([i == big for i in p]):
		return len(p)
	return 1

def main():
	for test in range(int(input())):
		_ = input()
		password = list(map(int, input().split()))
		result = solution(password)
		print(result)
main()


for ctr in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	for i in range(1, N):
		if a[i] != a[i - 1]:
			print(1)
			break
	else:
		print(N)


import sys

def main():
	t = Iint()
	for _ in range(t):
		n = Iint()
		a = Ilist()
		if a == [a[0]] * n:
			print(n)
		else:
			print(1)
en = enumerate
FIO = 10

def debug(*args, c=6):
	pass
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=sys.stderr)
BUFSIZE = 8 * 1024

def Istr():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import os

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnt = 0
	for x in a:
		if x == a[0]:
			cnt += 1
	if cnt == n:
		print(len(a))
	else:
		print('1')


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		a.sort()
		if a[0] == a[-1]:
			print(n)
		else:
			print(1)
solve()


tc = int(input())
for i in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = 1
	for i in range(n - 1):
		if arr[i] == arr[i + 1]:
			cnt += 1
	if cnt == n:
		print(n)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	maxi = max(lst)
	mini = min(lst)
	if maxi == mini:
		print(n)
	else:
		print(1)


import sys
from decimal import Decimal
import math
from itertools import combinations, product
import bisect
from collections import Counter, deque, defaultdict
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def lcm(a: int, b: int) -> int:
	return a * b // math.gcd(a, b)

def Main():
	for _ in range(read_int()):
		n = read_int()
		a = read_int_list()
		a_cnt = Counter(a)
		if len(a_cnt) == 1:
			print(len(a))
		else:
			print(1)
Main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		if a[i] != a[0]:
			print(1)
			break
		if i == n - 1:
			print(n)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == l[-1]:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ok = 1
	for t in l:
		if t != l[0]:
			ok = 0
	if not ok:
		print(1)
	else:
		print(n)


def _i():
	return int(input())

def _il():
	return [int(x) for x in input().split()]

def _iil():
	n = _i()
	a = _il()
	assert n == len(a)
	return a

def solve(a):
	if all((x == a[0] for x in a)):
		return len(a)
	return 1
for _ in range(int(input())):
	a = _iil()
	print(solve(a))


def main():
	t = int(input())
	for j in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		for i in range(n - 1):
			if a[i] != a[i + 1]:
				print(1)
				break
		else:
			print(n)
main()


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().split())
inl = lambda : list(map(int, input().split()))
ans = []
t = ini()
for _ in range(t):
	n = ini()
	a = inl()
	ans.append(n if len(set(a)) == 1 else 1)
print('\n'.join(map(str, ans)))


num_cases = int(input())
for case_num in range(num_cases):
	n = int(input())
	a = map(int, input().split())
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


for case in range(int(input())):
	pLength = int(input())
	pasword = [i for i in map(int, input().split())]
	pasword.sort()
	if pasword[0] == pasword[pLength - 1]:
		print(pLength)
	else:
		print(1)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, inf, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		a = inlist()
		if a.count(a[0]) == n:
			print(n)
		else:
			print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	arr = gil()
	allEqual = True
	for i in range(1, n):
		if arr[i] != arr[0]:
			allEqual = False
			break
	if allEqual:
		print(n)
	else:
		print(1)


for testcases in range(int(input())):
	num = int(input())
	l = list(map(int, input().split()))
	if l.count(l[0]) == num:
		print(num)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = a[0]
	flag = 0
	for j in range(1, n):
		if a[j] != x:
			flag = 1
			break
	if flag == 0:
		print(n)
	else:
		print(1)


def main():
	t = int(input())
	for tt in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		k = set(a)
		if len(k) == 1:
			print(n)
		else:
			print(1)
main()


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	if all((i == arr[0] for i in arr)):
		print(len(arr))
	else:
		print(1)
	t -= 1


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(a[0]) == n:
		print(n)
	else:
		print(1)


import sys, math, cmath, time
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


testcase = int(input(''))
ans = []

def password(num, length):
	res = length
	for i in range(1, length):
		if num[i] != num[i - 1]:
			res = 1
	ans.append(res)
for _ in range(testcase):
	length = int(input(''))
	num = list(map(int, input().split()))
	password(num, length)
for _ in range(len(ans)):
	print(ans.pop(0))


def solve():
	kek = input()
	a = sorted(list(map(int, input().split())))
	if a[0] == a[-1]:
		print(len(a))
	else:
		print(1)
[solve() for x in range(int(input()))]


from sys import stdin, stdout
from collections import Counter, OrderedDict
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(t,) = mp()
for _ in range(t):
	(n,) = mp()
	a = Counter(mp())
	if len(a) == 1:
		cout(str(n) + '\n')
	else:
		cout('1\n')


T = int(input())
for _ in range(T):
	length = int(input())
	a = list(map(int, input().split()))
	if sum([x == a[0] for x in a]) == length:
		result = length
	else:
		result = 1
	print(result)


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	c = a[0]
	b = False
	for i in a:
		if i != c:
			b = True
			break
	if b:
		print('1')
	else:
		print(n)


T = int(input())
for Tx in range(T):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	s = {i for i in a}
	if len(s) == 1:
		print(len(a))
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	if all((l[j] == l[j + 1] for j in range(n - 1))):
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 1
	if max(l) == min(l):
		f = n
	print(f)


try:
	for i1 in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		if a.count(a[0]) != n:
			print(1)
		elif a.count(a[0]) == n:
			print(n)
except:
	pass


t = int(input())
for T in range(t):
	p = 0
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n - 1):
		if l[i] != l[i + 1]:
			p = 1
			break
	if p == 0:
		print(n)
	else:
		print(1)


l = []
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	if len(s) == 1:
		l.append(len(a))
	else:
		l.append(1)
for i in l:
	print(i)


T = int(input())
for t in range(T):
	n = int(input())
	keys = list(map(int, input().strip().split()))
	digits = set(keys)
	if len(digits) == 1:
		print(n)
	else:
		print(1)


t = int(input())
temp_arr = []

def shortest_passwordLen(a_list, n):
	a_list = sorted(a_list)
	if a_list[0] == a_list[n - 1]:
		return n
	else:
		return 1
for i in range(t):
	n = int(input())
	a_list = list(map(int, input().split()))
	shortest_pass = shortest_passwordLen(a_list, n)
	temp_arr.append(shortest_pass)
for j in range(len(temp_arr)):
	print(temp_arr[j])


import math
import os
import random
import re
import string
from sys import *
from collections import *

def bs(arr, x, l, r):
	if l <= r:
		mid = (r + l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return bs(arr, x, l, mid - 1)
		else:
			return bs(arr, x, mid + 1, r)
	else:
		return -1

def solve():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, stdin.readline().strip().split()))
		s = list(set(l))
		if len(s) == 1:
			print(n)
		else:
			print(1)
solve()


a = int(input())
for i in range(a):
	b = int(input())
	c = set(map(int, input().split()))
	if len(c) == 1:
		print(b)
	else:
		print(1)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	c = a.count(a[0])
	if c == n:
		print(n)
	else:
		print(1)
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	stack = []
	for x in arr:
		while len(stack) >= 2 and stack[-2] + stack[-1] != x and (stack[-2] != stack[-1]):
			a = stack.pop()
			b = stack.pop()
			stack.append(a + b)
		stack.append(x)
		while len(stack) >= 3 and stack[-3] != stack[-2] + stack[-1] and (stack[-2] != stack[-1]):
			a = stack.pop()
			b = stack.pop()
			stack.append(a + b)
	while len(stack) >= 2 and stack[-2] != stack[-1]:
		a = stack.pop()
		b = stack.pop()
		stack.append(a + b)
	print(len(stack))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	for i in a:
		s.add(i)
	if len(s) == 1:
		print(len(a))
	else:
		print(1)


for _ in range(0, int(input())):
	n = int(input())
	list1 = list(map(int, input().strip().split()))[:n]
	if list1.count(list1[0]) == len(list1):
		print(len(list1))
	else:
		print(1)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
for case in range(1, itg() + 1):
	n = itg()
	st = set(mpint())
	if len(st) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(n)
		continue
	if n == 2 and l[0] == l[1]:
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 0
	for num in range(n - 1):
		if l[num] == l[num + 1]:
			pass
		else:
			flag = 1
			break
	if flag == 0:
		print(n)
	else:
		print(1)


from sys import stdin, stdout
import math
from collections import deque
input = stdin.readline

def print(*args, end='\n'):
	s = []
	for i in args:
		s.append(str(i) + ' ')
	s = ''.join(s)
	stdout.write(s + end)

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	p = max(l)
	q = min(l)
	if p == q:
		print(n)
	else:
		print(1)
	t -= 1


for _ in [0] * int(input()):
	p = int(input())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print(len(arr))
	else:
		print(1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = True
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			ans = False
	if ans:
		print(n)
	else:
		print(1)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().strip().split()))
		s = set()
		for e in a:
			s.add(e)
		if len(s) == 1:
			print(n)
		else:
			print(1)
main()


a = input()
for x in range(int(a)):
	b = input()
	c = input().split(' ')
	list1 = [int(i) for i in c]
	if len(set(list1)) == 1:
		print(len(list1))
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	fl = True
	y = b[0]
	for x in b[1:]:
		if x != y:
			fl = False
	if fl:
		print(n)
	else:
		print(1)


def solve_password_problem(list_num):
	i = list_num[0]
	for k in list_num:
		if k != i:
			return 1
	return len(list_num)
n = int(input().strip())
for i in range(n):
	range_number = input()
	try_time = input().strip().split(' ')
	try_time = [int(i) for i in try_time]
	result = solve_password_problem(try_time)
	print(result)


t = int(input())
for i in range(t):
	w = int(input())
	k = list(map(int, input().split()))
	c = len(set(k))
	if c > 1:
		print(1)
	elif c <= 1:
		print(len(k))


def solve(n, arr):
	for i in range(n):
		if arr[i] != arr[0]:
			return 1
	return n
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	hm = {}
	for i in range(n):
		hm[arr[i]] = hm.get(arr[i], 0) + 1
	if len(hm) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(p) for p in input().split()]
	if len(set(arr)) == 1:
		print(len(arr))
	else:
		print(1)


for _ in [0] * int(input()):
	n = int(input())
	arr = [int(a) for a in input().split()]
	const = arr[0]
	flag = True
	for i in arr:
		if i != const:
			flag = False
			break
	if flag == False:
		print(1)
	else:
		print(n)


from sys import stdin
import math
A = int(stdin.readline())
for t in range(0, A):
	B = int(stdin.readline())
	C = list(map(int, stdin.readline().split()))
	if len(set(C)) == 1:
		print(B)
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == l[-1]:
		print(len(l))
	else:
		print(1)


for _ in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	f = 0
	for i in range(1, a):
		if l[i - 1] != l[i]:
			f = 1
	if f == 0:
		print(a)
	else:
		print(1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	if n == 1:
		print(1)
	else:
		s = set(a)
		if len(s) > 1:
			print(1)
		else:
			print(n)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	cnt = 0
	s = set(l)
	if len(s) == 1:
		print(len(l))
	else:
		print(1)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	if len(set(l)) == 1:
		print(len(l))
	else:
		print(1)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = inar()
		counter = 0
		for i in range(1, n):
			if arr[i] == arr[0]:
				continue
			else:
				counter = 1
				break
		if counter == 0:
			print(len(arr))
		else:
			print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = True
	for i in a:
		if i != a[0]:
			p = False
			break
	if not p:
		print(1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	se = set(ar)
	if len(se) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	max = x[-1]
	times = x.count(max)
	if times == n:
		print(n)
	elif times == 1:
		print(1)
	else:
		print(1)


N = int(input())
for _ in range(N):
	n = int(input())
	a = [0] * n
	line = input()
	values = line.split()
	for i in range(n):
		a[i] = int(values[i])
	res = 0
	d = max(a)
	c = a.count(d)
	if c == n:
		print(n)
	else:
		print(1)


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	e = 0
	for j in range(0, len(a) - 1):
		if a[j + 1] == a[j]:
			e = e + 1
	if e == len(a) - 1:
		print(len(a))
	else:
		print(1)


t = int(input())
for q in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	L.sort()
	if L[0] == L[-1]:
		print(n)
	else:
		print(1)


t = int(input())
for test in range(t):
	n = int(input())
	nums = [int(x) for x in input().split()]
	flag = 0
	for i in range(n - 1):
		if nums[i + 1] == nums[i]:
			continue
		else:
			flag = 1
			break
	if flag == 0:
		print(n)
	else:
		print(1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	ok = False
	for i in range(1, n):
		if a[i] != a[i - 1]:
			print(1)
			ok = True
			break
	if ok:
		continue
	print(n)


t = int(input())
c = []
for i in range(t):
	n = int(input())
	a = [int(y) for y in input().split()]
	j = 0
	p = 0
	while j < n - 1:
		if a[j] != a[j + 1]:
			p = 1
			break
		j += 1
	if p == 0:
		c.append(n)
	else:
		c.append(1)
for k in c:
	print(k)


for _ in range(int(input())):
	n = input()
	l = set(map(int, input().split()))
	if l.__len__() == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	lens = int(input())
	arrs = [int(x) for x in input().split()]
	print(lens if len(set(arrs)) == 1 else 1)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	flag = True
	x = l[0]
	for i in l[1:]:
		if x != i:
			flag = False
	if not flag:
		print(1)
	else:
		print(n)


for _ in range(int(input())):
	pass_length = int(input())
	pwd = list(map(int, input().strip().split()))
	if len(set(pwd)) == 1:
		print(len(pwd), end='\n')
	else:
		print('1', end='\n')


for _ in range(int(input())):
	n = int(input())
	lol = [int(n) for n in input().split()]
	if len(set(lol)) == 1:
		print(n)
	else:
		print(1)


def main(args):
	for i in range(int(input())):
		input()
		x = []
		n = list(map(int, input().split(' ')))
		r = len(n)
		for j in range(0, len(n)):
			if n[j] != n[j - 1]:
				r = 1
			x.append(r)
		l = list(set(x))
		l.sort()
		print(l[0])
import sys
sys.exit(main(sys.argv))


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l = [0] + l
	if any((l[i] != l[i + 1] for i in range(1, n))):
		print(1)
	else:
		print(n)


inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
(t,) = inp()
for _ in range(t):
	(n,) = inp()
	print(n if len(set(inp())) == 1 else 1)


import sys
import random
from fractions import Fraction
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

def flinput():
	return list(fiinput())

def rlinput():
	return list(map(int, input().split()))

def trinput():
	return tuple(rinput())

def srlinput():
	return sorted(list(map(int, input().split())))

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	print(n if len(set(rlinput())) == 1 else 1)
for TESTING in range(iinput()):
	main()


t = int(input())
for t in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	fl = 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			fl = 0
			break
	if fl:
		print(n)
	else:
		print(1)


test_cases = int(input())
for test_case in range(test_cases):
	n = int(input())
	a = list(map(int, input().split()))
	if max(a) == min(a):
		print(n)
	else:
		print(1)


(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, dgraphs, mod) = (lambda : sorted(zz()), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for i in range(num):
	n = int(z())
	l = zz()
	p = set(l)
	if len(p) == 1:
		print(n)
		continue
	print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split(' ')))
	if min(lst) == max(lst):
		print(n)
	else:
		print(1)


def checkArr(arr, arrLen):
	for i in range(0, arrLen - 1):
		if arr[i] != arr[i + 1]:
			return 1
	return arrLen
testCases = input()
for i in range(int(testCases)):
	arrLen = input()
	arr = list(map(int, input().split()))
	ans = checkArr(arr, int(arrLen))
	print(ans)


import sys
input = sys.stdin.readline

def solve():
	n = map(int, input())
	ls = list(map(int, input().split()))
	if len(set(ls)) == 1:
		print(len(ls))
	else:
		print(1)
T = int(input())
for _ in range(T):
	solve()


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
sys.setrecursionlimit(10 ** 6)
from queue import PriorityQueue
from collections import Counter as cc
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
while t > 0:
	n = int(input())
	A = list(set(map(int, input().split())))
	if len(A) > 1:
		print(1)
	else:
		print(n)
	t -= 1


t = int(input())
for case in range(t):
	n = int(input())
	passwords = list(map(int, input().split()))
	if all([i == passwords[0] for i in passwords]):
		print(n)
	else:
		print(1)


tests = int(input())
while tests > 0:
	tests -= 1
	n = int(input())
	d = list(map(int, input().split()))
	s = set(d)
	if len(s) == 1:
		print(n)
		continue
	elif len(s) == 2 and 0 in s:
		print(n - d.count(0))
	else:
		print(1)


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	if min(a) == max(a):
		print(n)
	else:
		print(1)


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if len(a) == 2:
		if a[0] == a[1]:
			print(2)
		else:
			print(1)
	elif len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


number = int(input())
for _ in range(number):
	begin = input()
	listo = [int(k) for k in input().split(' ')]
	seto = set(listo.copy())
	if len(seto) == 1:
		print(len(listo))
	else:
		print(1)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	if len(set(lis)) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split(' ')))
	if A.count(A[0]) == n:
		print(n)
	else:
		print(1)


t = int(input())
for abc in range(t):
	numOfElemets = int(input())
	myList = list(map(int, input().split()))
	if len(set(myList)) >= 2:
		print(1)
	else:
		print(numOfElemets)


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 1
	d = {}
	for i in range(n):
		d[arr[i]] = 0
	if len(d) == 1:
		print(len(arr))
	else:
		print(1)


import sys
from math import sqrt
from collections import OrderedDict
inpt = sys.stdin.readline

def inp():
	return int(inpt())

def inlist():
	return list(map(int, inpt().split()))

def instr():
	s = inpt()
	return list(s[:len(s) - 1])

def invr():
	return map(int, inpt().split())

class node(object):

	def __init__(self, x, p, h):
		(self.x, self.p, self.h) = (x, p, h)
		self.children = []

	def add_child(self, obj):
		self.children.append(obj)

def main():
	t = inp()
	for l in range(t):
		n = inp()
		a = inlist()
		eq = True
		for i in range(1, n):
			if a[i] != a[i - 1]:
				eq = False
				break
		if eq:
			print(n)
		else:
			print(1)
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(o) for o in input().split()]
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


t = int(input())
while t:
	n = int(input())
	a = [int(i) for i in input().split()]
	answ = n
	for i in range(1, n):
		if a[i - 1] != a[i]:
			answ = 1
			break
	print(answ)
	t -= 1


def equal(a):
	check = a[0]
	for i in range(len(a)):
		if check != a[i]:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if equal(a):
		print(len(a))
	else:
		print(1)


import collections

def solve(lst):
	for i in range(len(lst) - 1):
		if lst[i] != lst[i + 1]:
			return 1
	return len(lst)

def sort(key):
	return key[0]
ans = []
n = int(input())
for i in range(n):
	m = int(input())
	lst = list(map(int, input().split()))
	ans.append(solve(lst))
for i in ans:
	print(i)


def solve(arr):
	if arr.count(arr[0]) == len(arr):
		print(arr.count(arr[0]))
		return
	else:
		print(1)
t = int(input())
for i in range(t):
	input()
	solve(list(map(int, input().split())))


for i in range(int(input())):
	n = int(input())
	a = input().split()
	a = list(map(lambda x: int(x), a))
	m = 0
	for i in range(len(a)):
		if a[i] > m:
			m = a[i]
	c = 0
	for i in range(len(a)):
		if a[i] == m:
			c += 1
	if c == len(a):
		print(c)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = []
	i = 0
	j = i + 1
	S = set(list1)
	if len(S) > 1:
		print(1)
	else:
		print(n)


for _ in range(int(input())):
	inp = int(input())
	res = set(map(int, input().split()))
	if len(res) == 1:
		print(inp)
	else:
		print('1')


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	a = lin()
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		(a1, ls) = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	n = I()
	a = LI()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict
for _ in range(ri()):
	n = ri()
	l = ria()
	s = set(l)
	k = len(s)
	if k == 1:
		wi(n)
	else:
		wi(1)


import sys
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) > 1:
		print(1)
	else:
		print(n)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	back = arr[0]
	for each in arr:
		if each != back:
			break
	else:
		print(n)
		continue
	print('1')


import sys
a = int(input())
while a > 0:
	b = input()
	c = list(map(int, input().strip().split()))
	if len(list(set(c))) == 1:
		print(len(c))
	else:
		print(1)
	a -= 1


def solve(n, li):
	if len(set(li)) == 1:
		return len(li)
	else:
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().strip().split()))
	print(solve(n, li))


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	if n == 2:
		ans.append(1) if p[0] != p[1] else ans.append(2)
		continue
	one_number = True
	for j in range(0, n - 1):
		if p[j + 1] != p[j]:
			one_number = False
			break
	if one_number:
		ans.append(n)
	else:
		ans.append(1)
print(*ans, sep='\n')


test = int(input())
for i in range(test):
	n = int(input())
	vals = [int(x) for x in input().split()]
	same = True
	for i in range(n - 1):
		if vals[i] != vals[i + 1]:
			same = False
			break
	if same:
		print(n)
	else:
		print(1)


for i1 in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	dict = {}
	for i in l:
		if i not in dict:
			dict[i] = 1
		else:
			dict[i] += 1
	if len(dict) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	temp = input()
	arr = list(map(int, input().split()))
	ans = len(arr)
	for i in range(1, len(arr)):
		if arr[i] != arr[i - 1]:
			ans = 1
			break
	print(ans)


import math
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


answer = []
t = int(input())
for _ in range(t):
	n = int(input())
	liste = list(map(int, input().split(' ')))
	m = max(liste)
	if liste == [m] * n:
		answer.append(str(n))
	else:
		answer.append(str(1))
print('\n'.join(answer))


t = int(input())
for q in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if arr.count(max(arr)) == n:
		print(n)
	else:
		print(1)


def res(arr, n):
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			return 1
	return n
t = int(input())
for ite in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(res(arr, n))


t = int(input())
for i in range(t):
	n = int(input())
	l = input().split()
	allEqual = True
	for i in range(1, len(l)):
		if l[i] != l[0]:
			allEqual = False
	if allEqual:
		print(n)
	else:
		print(1)


test = int(input())
result = []
for t in range(test):
	n = int(input())
	a = [int(num) for num in input().split()]
	check = False
	for x in range(n - 1):
		if a[x] != a[n - 1]:
			check = True
	if check == False:
		result.append(n)
	else:
		result.append(1)
for count in range(len(result)):
	print(result[count])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class union_find:

	def __init__(self, n):
		self.n = n
		self.rank = [0] * n
		self.parent = [int(j) for j in range(n)]

	def union(self, i, j):
		i = self.find(i)
		j = self.find(j)
		if self.rank[i] == self.rank[j]:
			self.parent[i] = j
			self.rank[j] += 1
		elif self.rank[i] > self.rank[j]:
			self.parent[j] = i
		else:
			self.parent[i] = j

	def find(self, i):
		temp = i
		if self.parent[temp] != temp:
			self.parent[temp] = self.find(self.parent[temp])
		return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC, defaultdict as dd
MOD = int(1000000000.0 + 7)

def main():
	for t in range(int(input())):
		n = int(input())
		l = [int(j) for j in input().split()]
		s = set(l)
		if len(s) == 1:
			print(len(l))
		else:
			print(1)
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = 1
	ma = 0
	for i in range(n - 1):
		if arr[i] == arr[i + 1]:
			c += 1
		else:
			ma = max(c, ma)
			c = 1
	ma = max(c, ma)
	if ma != n:
		print(1)
	else:
		print(n)


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	print(n if min(li) == max(li) else '1')
	t -= 1


for _ in range(int(input())):
	z = int(input())
	l = list(map(int, input().split()))
	ans = 1
	for i in range(z - 1):
		if l[i] == l[i + 1]:
			ans += 1
	if ans == z:
		print(z)
	else:
		print(1)


t = int(input())
for o in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
	else:
		f = 0
		for i in range(n - 1):
			if a[i] != a[i + 1]:
				f = 1
				print(1)
				break
		if f == 0:
			print(n)


def solve(N, Arr):
	if len(set(Arr)) == 1:
		print(N)
	else:
		print(1)
t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	solve(n, a)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	found = 0
	if n == 1:
		found = 1
	else:
		for k in range(len(lis) - 1):
			if lis[k] != lis[k + 1]:
				found = 1
				break
	if found == 0:
		print(n)
	else:
		print(1)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	l1 = len(a)
	l2 = len(s)
	if l2 == 1:
		print(n)
	else:
		print(1)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if n == 1:
		print(n)
		continue
	tset = set(arr)
	if len(tset) == 1:
		print(n)
		continue
	print(1)


t = int(input())
n = 0
arr = []
for k in range(t):
	n = int(input())
	arr = input().split()
	arr = [int(arr[i]) for i in range(n)]
	if max(arr) == min(arr):
		print(n)
	else:
		print(1)


from collections import Counter

def solve(a, n):
	d = Counter(a)
	if len(d) == 1:
		return n
	return 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(a, n))


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(n if 1 == len(set(arr)) else 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 1
	while i < n and a[i] == a[i - 1]:
		i += 1
	if i == n:
		print(n)
	else:
		print(1)


for not_req in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	alleq = True
	curr = arr[0]
	for i in range(n):
		if curr != arr[i]:
			alleq = False
			break
	if alleq:
		print(len(arr))
	else:
		print(1)


def password(a):
	if max(a) == min(a):
		return len(a)
	else:
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(password(a))


tests = int(input())
for t in range(tests):
	a_length = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	if len(s) == 1:
		print(len(a))
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	h = set()
	flag = False
	h.add(a[0])
	for num in a:
		if num in h:
			pass
		else:
			flag = True
			break
	if flag:
		print(1)
	else:
		print(n)


def get_primeFactor(n):
	res = [1]
	x = 2
	while x * x <= n:
		while n % x == 0:
			res.append(x)
			n //= x
		x += 1
	if n > 1:
		res.append(n)
	return res

def getFactor(n):
	res = {1}
	x = 2
	while x * x <= n:
		if n % x == 0:
			res.add(x)
			res.add(n // x)
		x += 1
	return res
for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	if all((i == a[0] for i in a)):
		print(len(a))
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = 0
	i = 0
	for i in range(len(a)):
		if a[i] == a[0]:
			b += 1
		else:
			pass
	if b == n:
		print(n)
	else:
		print(1)


t = int(input())
N = []
A = []
for i in range(t):
	N.append(int(input()))
	A.append(list(map(int, input().split())))
a = [[x for x in A[i] if x != A[i][0]] for i in range(t)]
for i in range(t):
	if len(a[i]) > 0:
		print(1)
	else:
		print(N[i])


def find(li, n):
	c = 1
	for i in range(n - 1):
		if li[i] == li[i + 1]:
			c = c + 1
	if c == n:
		print(n)
	else:
		print('1')
t = int(input())
while t > 0:
	n = int(input())
	li = [int(ele) for ele in input().split()]
	find(li, n)
	t = t - 1


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [1] * T
for qu in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	if len(set(A)) == 1:
		Ans[qu] = len(A)
print('\n'.join(map(str, Ans)))


import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time
readline = sys.stdin.readline
IPS = lambda : readline().rstrip()
IP = lambda : int(readline().rstrip())
MP = lambda : map(int, readline().split())
LS = lambda : list(map(int, readline().split()))

def solve():
	for _ in range(IP()):
		n = IP()
		arr = LS()
		if len(set(arr)) == 1:
			print(n)
		else:
			print(1)
solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	flag = True
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			flag = 0
	if flag:
		print(n)
	else:
		print(1)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		i = a[0]
		flag = False
		for c in a[1:]:
			if c != i:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(n)
	return
main()


t = int(input())
while t:
	n = int(input())
	a = [int(i) for i in input().split()]
	flag = False
	prev = None
	for ele in a:
		if prev is None:
			prev = ele
		elif ele != prev:
			flag = True
			break
	if flag:
		print(1)
	else:
		print(n)
	t -= 1


import math
import sys

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphbates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
t = int(input())
for _i in range(t):
	n = int(input())
	ls = inp()
	if len(set(ls)) == 1:
		print(n)
	else:
		print(1)


exec(int(input()) * 'input();arr=list(map(int,input().split()));print([arr.count(arr[0]),1][len(set(arr))>1]);')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	found = False
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			found = True
	if not found:
		print(n)
	else:
		print(1)


def length(arr):
	if len(set(arr)) == 1:
		return len(arr)
	else:
		return 1
t = int(input())
ans = []
for i in range(0, t):
	let = int(input())
	n = input().split()
	n = list(map(int, n))
	ans.append(length(n))
for j in ans:
	print(j)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	m -= 1
	(n,) = I()
	arr = I()
	flag = 0
	for i in range(n - 1):
		if arr[i] != arr[i + 1]:
			flag = 1
			break
	if flag == 0:
		print(n)
	else:
		print(1)


t = int(input())
while t > 0:
	k = int(input())
	num = input()
	num = num.split(' ')
	s = set()
	ans = len(num)
	for n in num:
		if not s:
			s.add(n)
		elif n not in s:
			ans = 1
			break
	print(ans)
	t -= 1


from sys import stdin, stdout
from collections import defaultdict
import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	pre = array[0]
	equal = True
	for i in array:
		if i != pre:
			equal = False
			break
		pre = i
	if equal:
		print(n)
	else:
		print(1)


import math
t = int(input())
for q in range(t):
	n = int(input())
	L = [int(i) for i in input().split()]
	first = 0
	second = 0
	for i in L:
		if first == 0:
			first = i
		elif i != first:
			second = i
			break
	if second == 0:
		print(n)
	else:
		print(1)


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			print(1)
			break
	else:
		print(n)
	t -= 1


import math
test = int(input())
for t in range(test):
	n = int(input())
	A = list(map(int, input().split()))
	if len(set(A)) == 1:
		print(n)
	else:
		print(1)


from math import *
from collections import *
from random import *
from decimal import Decimal
from heapq import *
from bisect import *
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())

def st1():
	return input().rstrip('\n')
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	x = a[0]
	fl = 0
	for i in range(n):
		if x == a[i]:
			continue
		fl = 1
		break
	if fl == 0:
		print(n)
	else:
		print(1)


from sys import stdin, stdout

def find(arr, N):
	if len(set(arr)) == 1:
		return N
	return 1

def main():
	for _ in range(int(stdin.readline())):
		N = int(stdin.readline())
		arr = list(map(int, stdin.readline().split()))
		print(find(arr, N))
main()


from math import *
from copy import *
from string import *
from random import *
from sys import stdin, stdout
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time
from queue import Queue

def seive(n):
	l = [True]
	l = l * (n + 1)
	for i in range(2, int(sqrt(n)) + 1):
		if l[i] == True:
			val = i * i
			while val < len(l):
				l[val] = False
				val += i
	prime = []
	for i in range(2, len(l)):
		if l[i] == True:
			prime.append(i)
	return prime

def dp(l, i, n, val, ans):
	if i >= n or val < 0:
		return 1000000
	elif val == 0:
		return 0
	else:
		if ans[i] == 1000000:
			ans[i] = min(min(1 + dp(l, i + 1, n, val - l[i], ans), 1 + dp(l, i, n, val - l[i], ans)), dp(l, i + 1, n, val, ans))
		return ans[i]
from queue import Queue

def factors(n):
	l = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def check1(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v -= 1

def check2(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v += 1

def up(n):
	j = n - 1
	while j > 0:
		if n % j == 0:
			break
		j -= 1
	return j

def fac(n):
	c = 1
	i = 1
	while i <= n:
		c *= i
		i += 1
	return c

def check_happy(n):
	ss = set()
	print(n)
	while n != 1:
		val = n
		s = 0
		print(val)
		while val != 0:
			s += (val % 10) ** 2
			val = val // 10
		print(val)
		print('hi')
		if val in ss:
			return False
		else:
			n = val
			ss.add(n)
	return True

def update(a, b):
	c = 1
	val = a
	while a < b:
		print(c, a)
		c += c
		a += a
	print(1)
	while a > b:
		print()
		a -= val
		c -= 1
	return c
import random as rand

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
from itertools import permutations

def insertion_sort(arr):
	for i in range(len(arr)):
		j = i
		while j > 0:
			if arr[j] < arr[j - 1]:
				temp = arr[j]
				arr[j] = arr[j - 1]
				arr[j - 1] = temp
			j -= 1
	return arr

def quick_sort(arr, low, high):
	i = low
	j = high
	while i < j:
		if arr[i] > arr[low] and arr[j] < arr[low]:
			temp = arr[i]
			arr[i] = arr[j]
			arr[j] = arr[i]
			i += 1
			j -= 1
		elif arr[i] <= arr[low]:
			i += 1
		elif arr[j] >= arr[low]:
			j -= 1
	print(i, j)
	toto = arr[j]
	arr[j] = arr[low]
	arr[low] = toto
	return j

def dodo(arr, low, high):
	if low < high:
		val = quick_sort(arr, low, high)
		dodo(arr, low, val - 1)
		dodo(arr, val + 1, high)

def dp(arr, c, n, k, z, ans):
	if k == 0:
		return ans
	elif c == 0:
		return dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1])
	elif c == n - 1:
		if z == 0:
			return 0
		else:
			return dp(arr, c - 1, n, k - 1, z - 1, ans + arr[c - 1])
	elif z == 0:
		return dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1])
	else:
		return max(dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1]), dp(arr, c - 1, n, k - 1, z - 1, ans + arr[c - 1]))

def check(arr, val):
	a = -1
	for i in range(len(arr)):
		if arr[i][len(arr[i]) - 1] == val:
			a = i
			break
	return a

def reverse(s, i, ans):
	if i >= len(s):
		return ans
	else:
		return reverse(s, i + 1, s[i] + ans)

def update(arr, i, j, n, m):
	if i >= 0 and i < n and (j >= 0) and (j < m):
		if arr[i][j] == 1:
			arr[i][j] == 2
			return [i, j]
	return [-1, -1]
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split(' ')))
	l.sort()
	if l[0] == l[n - 1]:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	list1 = [int(i) for i in input().split()]
	list1.sort()
	if list1[0] != list1[-1]:
		print(1)
	else:
		print(len(list1))


t = int(input())
for i in range(t):
	ctr = 0
	n = int(input())
	l = list(map(int, input().split()))
	for x in range(1, n):
		if l[x] != l[x - 1]:
			ctr += 1
	if ctr == 0:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	p = set(l)
	if len(p) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	curr = arr[0]
	found = False
	for i in range(1, n):
		if curr != arr[i]:
			found = True
	if found:
		print(1)
	else:
		print(n)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		good = False
		for i in range(1, n):
			if a[i] != a[0]:
				good = True
				break
		if not good:
			print(n)
		else:
			print(1)
main()


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	n = max(a)
	f = 1
	for i in a:
		if i != n:
			f = 0
			break
	if not f:
		print(1)
	else:
		print(len(a))


a = int(input())
for i in range(a):
	b = int(input())
	arr = list(map(int, input().split()))
	s = set(arr)
	if len(s) == 1:
		print(len(arr))
	else:
		print(1)


t = int(input())
for i in range(t):
	ln = int(input())
	lst1 = list(map(int, input().split()))
	a = set(lst1)
	if len(a) == 1:
		print(ln)
	else:
		print(1)


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	temparr = input()
	temparr = temparr.split()
	arr = []
	dicts = {}
	for i in temparr:
		arr.append(int(i))
		i = int(i)
		if i not in dicts:
			dicts[i] = 1
		else:
			dicts[i] += 1
	arr = sorted(arr)
	if n == 1:
		print(1)
		continue
	if n == 2 and arr[-1] == arr[-2]:
		print(2)
		continue
	if n == 2 and arr[-1] != arr[-2]:
		print(1)
		continue
	if len(dicts) == 1:
		print(n)
		continue
	if len(dicts) >= 2:
		print(1)
		continue


t = int(input())
while t > 0:
	t -= 1
	s = int(input())
	k = list(map(int, input().split()))
	if len(set(k)) == 1:
		print(len(k))
	else:
		print('1')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mini = min(a)
	maxi = max(a)
	if mini == maxi:
		print(n)
	else:
		print(1)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		c = Counter(l)
		if len(c.keys()) == 1:
			print(n)
		else:
			print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	st = set()
	for i in a:
		st.add(i)
	if len(st) >= 2:
		print(1)
	else:
		print(n)


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	if len(a) == a.count(a[0]):
		print(len(a))
	else:
		print(1)
	i += 1


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def read(func=int):
	return map(func, input().split())
t = int(input())
while t:
	n = int(input())
	nums = list(read())
	if len(set(nums)) == 1:
		print(len(nums))
	else:
		print(1)
	t -= 1


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque
from collections import defaultdict
MOD = 1000000007

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans

def to_zero(n, s):
	lst = s[0]
	ans = []
	for i in range(n):
		if lst == s[i]:
			continue
		elif lst == '0':
			lst = '1'
			ans.append(i)
		else:
			lst = '0'
			ans.append(i)
	if lst == '1':
		ans.append(n)
	return ans
for _ in range(int(input())):
	(n, a) = na()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


import sys
import bisect as bi
import math
from collections import defaultdict as dd
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
s1 = 'abcdefghijklmnopqrstuvwxyz'
res = []
ans = []

def solve(targ, ans, res, l):
	if targ < 0:
		return []
	if targ == 0:
		if ans < res:
			ans = res
		return ans
	for i in range(25, -1, -1):
		if targ - l[i] >= 0:
			x = res.append(s1[i])
			if len(solve(targ - l[i], ans, x, l)) > 0:
				return ans
	return []
for _ in range(inin()):
	n = inin()
	l = ain()
	if l.count(l[0]) == n:
		print(n)
	else:
		print(1)


for ii in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	h = set(a)
	if len(h) == 1:
		print(n)
	else:
		print(1)


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	_max_count = 0
	_max = max(arr)
	for i in range(n):
		if arr[i] == _max:
			_max_count += 1
	if _max_count == n:
		print(n)
	else:
		print(1)


T = int(input())
for t in range(T):
	n = int(input())
	q = input().split(' ')
	q = [int(x) for x in q]
	k = 0
	s = 0
	q1 = []
	for i in q:
		if i not in q1:
			q1 += [i]
			k += 1
		s += 1
		if k > 1:
			break
	if k == 1:
		print(s)
	else:
		print(1)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	x = a.count(max(a))
	if x == n:
		print(n)
	else:
		print(1)


query = int(input())
for _ in range(query):
	n = int(input())
	nums = list(map(int, input().split()))
	bnums = list(set(nums))
	if len(bnums) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	max_el = max(a)
	if a.count(max_el) == n:
		print(n)
	else:
		print(1)


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	t = a[0]
	for i in range(n):
		if a[i] != t:
			print(1)
			return
	print(n)
tt = int(input())
for test in range(tt):
	solve()


import collections
t = int(input())
res = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	if len(collections.Counter(a)) > 1:
		res.append(1)
	else:
		res.append(a.count(a[0]))
for i in res:
	print(i)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = True
	a.sort()
	for i in range(1, n):
		if a[i - 1] != a[i]:
			f = False
	if f:
		print(n)
	else:
		print(1)


import sys
for i in range(0, int(sys.stdin.readline())):
	leng = int(sys.stdin.readline())
	vllist = sys.stdin.readline().split()
	if leng == vllist.count(vllist[0]):
		sys.stdout.write(str(leng) + '\n')
	else:
		sys.stdout.write('1\n')


t = int(input())
for k in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	uniq_len = len(set(ar))
	print(n if uniq_len == 1 else 1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	a = int(input())
	x = list(map(int, input().split()))
	if max(x) == min(x):
		print(a)
	else:
		print(1)


test_cases = int(input())
for i in range(test_cases):
	password_length = int(input())
	password = set(map(int, input().split()))
	if len(password) == 1:
		print(password_length)
	else:
		print(1)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	if min(a) == max(a):
		print(len(a))
	else:
		print(1)


a = int(input())
for x in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	h = set(c)
	if len(h) == 1:
		print(len(c))
	else:
		print(1)


N = int(input())
data = []

def find_length(array, k):
	if k == 1:
		return 1
	else:
		count = 0
		queue = []
		prev = array[0]
		for i in range(1, k):
			cur = array[i]
			if cur != prev:
				prev += cur
				count += 1
			else:
				queue.append(prev)
				prev = cur
		while len(queue) > 0:
			cur = queue.pop()
			if cur != prev:
				prev += cur
				count += 1
			else:
				break
		count_2 = 0
		prev = array[1]
		queue_2 = []
		queue_2.append(array[0])
		for i in range(2, k):
			cur = array[i]
			if cur != prev:
				prev += cur
				count_2 += 1
			else:
				queue_2.append(prev)
				prev = cur
		while len(queue_2) > 0:
			cur = queue_2.pop()
			if cur != prev:
				prev += cur
				count_2 += 1
			else:
				break
		return min(k - count, k - count_2)
for _ in range(N):
	k = int(input())
	array = list(map(int, input().strip().split()))
	print(find_length(array, k))


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	S = set(A)
	if len(S) == 1:
		print(N)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	ar = [int(x) for x in input().split()]
	ar.sort()
	if ar[0] == ar[n - 1]:
		print(n)
	else:
		print(1)


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	res = n
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			res = 1
			break
	print(res)


import sys

def main():
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for i1 in [0] * t:
		n = int(input())
		nums = list(map(int, input().split()))
		if len(set(nums)) == 1:
			print(str(len(nums)))
			print('\n')
			continue
		else:
			print('1')
			print('\n')
			continue
main()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = LI()
	if aa.count(aa[0]) == n:
		print(n)
	else:
		print(1)


from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	ans = LI()
	if len(set(ans)) == 1:
		print(n)
	else:
		print(1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = RLL()
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
	else:
		diff = False
		for i in a[1:]:
			if i != a[0]:
				diff = True
				break
		if diff:
			print(1)
		else:
			print(n)


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	flag = True
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			flag = False
			break
	if flag:
		print(n)
	else:
		print(1)


from collections import Counter
cases = int(input())
for _ in range(cases):
	n = int(input())
	c = list(map(int, input().split()))
	if c.count(c[0]) == len(c):
		print(len(c))
	else:
		print(1)


import collections
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if len(collections.Counter(a)) == 1:
		print(n)
	else:
		print(1)


def ez():
	amountOfTimes = input()
	arrayWithAnswers = []
	for x in range(int(amountOfTimes)):
		amountOfNumbers = input()
		stringToList = input()
		array = [int(s) for s in stringToList.split(' ')]
		if len(set(array)) == 1:
			print(amountOfNumbers)
		else:
			print(1)
ez()


for t in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	tmp = a[0]
	flag = True
	for i in range(1, n):
		if a[i] != tmp:
			flag = False
			break
	if flag:
		print(n)
	else:
		print(1)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	n = inp()
	x = ip()
	if len(set(x)) == 1:
		print(n)
	else:
		print(1)


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	n = INT()
	arr = LIST()
	f = 0
	for i in range(1, n):
		if arr[0] != arr[i]:
			f = 1
			break
	if f == 1:
		print(1)
	else:
		print(n)


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, a):
	if len(set(a)) == 1:
		return len(a)
	return 1
t = read_int()
for case in range(t):
	n = read_int()
	a = read_ints()
	sol = solve(n, a)
	print(sol)


for _ in range(int(input())):
	n = int(input())
	ar = [int(x) for x in input().split()]
	if len(set(ar)) == 1:
		print(n)
	else:
		print(1)


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	prev = f = 0
	for i in range(n):
		if a[i] != a[0]:
			f = 1
			break
	if f == 1:
		print(1)
	else:
		print(len(a))


from sys import stdin, stdout
from collections import Counter
from collections import defaultdict
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
for i in range(ip()):
	n = ip()
	li = ai()
	if len(set(li)) == 1:
		print(n)
	else:
		print(1)


import sys
input = sys.stdin.buffer.readline
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
inst = lambda : input().decode().rstrip('\n\r')
INF = float('inf')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	if len(set(a)) == 1:
		print(len(a))
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	g = 0
	for i in range(n - 1):
		if p[0] == p[i + 1]:
			g = 1
		else:
			g = 0
			break
	if g == 1:
		print(n)
	else:
		print('1')


for _ in range(int(input())):
	am = int(input())
	arr = list(map(int, input().split()))
	if am == 1:
		print(1)
	else:
		s = set(arr)
		if len(s) != 1:
			print(1)
		else:
			print(am)


def check(arrayList1):
	if arrayList1[0] == arrayList1[len(arrayList1) - 1]:
		print(len(arrayList1))
	else:
		print('1')
t = int(input())
for i in range(0, t):
	n = int(input())
	lists1 = list((int(num) for num in input().strip().split()))[:n]
	lists1.sort()
	check(lists1)


import itertools
import math
for i in range(int(input())):
	length = int(input())
	List = list(map(int, input().split()))
	if len(set(List)) > 1:
		print(1)
	else:
		print(len(List))


t = int(input())
for i in range(0, t):
	m = int(input())
	arr = list(map(int, input().strip().split()))[:m]
	ct = 0
	for j in range(0, m - 1):
		if arr[j] == arr[j + 1]:
			ct += 1
	if ct == m - 1:
		print(m)
	else:
		print(1)


import math
import collections
import bisect

def arrPrint(a):
	return ' '.join([str(i) for i in a])

def gridPrint(a):
	return '\n'.join([' '.join([str(j) for j in a[i]]) for i in range(len(a))])

def isPalindrome(s):
	for i in range(len(s) // 2):
		if not s[i] == s[-i - 1]:
			return False
	return True

def primeCheck(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def solve(n, a):
	mx = max(a)
	for i in range(n):
		if not a[i] == mx:
			return 1
	return n
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = len(set(l))
	if k > 1:
		print(1)
	else:
		print(n)


from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	arr = iia()
	if len(set(arr)) == 1:
		print(n)
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	if max(arr) == min(arr):
		print(n)
	else:
		print(1)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	if all((a == aa[0] for a in aa)):
		print(len(aa))
	else:
		print(1)

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


import collections
t = int(input().strip(' '))
for _ in range(t):
	n = int(input().strip(' '))
	arr = list(map(int, input().strip(' ').split(' ')))
	d = collections.Counter(arr)
	if len(d) == 1:
		print(len(arr))
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	mm = max(a)
	mn = min(a)
	if mm != mn:
		print('1')
	else:
		print(len(a))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
	elif a.count(a[0]) == n:
		print(n)
	else:
		print(1)


t = int(input())
for w in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = 0
	for i in range(0, len(arr) - 1):
		if arr[i] != arr[i + 1]:
			flag = 1
			break
	if flag == 0:
		print(len(arr))
	elif flag == 1:
		print('1')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	if len(set(arr)) == 1:
		ans = len(arr)
	else:
		ans = 1
	print(ans)


tt = int(input())
while tt:
	tt -= 1
	n = int(input())
	ll = list(map(int, input().split()))
	l = set(ll)
	if len(l) == 1:
		print(len(ll))
	else:
		print(int(1))


num_test = int(input())

def solve(a, n):
	c = a[0]
	for j in range(1, n):
		if a[j] != c:
			return 1
	return n
for i in range(num_test):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(a, n))


from sys import stdin, stdout
test_cases = int(stdin.readline())
result = []
for _ in range(test_cases):
	n = int(stdin.readline())
	arr_a = list(map(int, stdin.readline().split()))
	i = 0
	min_arr = min(arr_a)
	max_arr = max(arr_a)
	if min_arr == max_arr:
		s = '{}'.format(n)
	else:
		s = '1'
	result.append(s)
stdout.write('\n'.join(result))


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = [int(i) for i in input().split()]
	if min(a) == max(a):
		print(n)
	else:
		print(1)


try:
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		s = set(l)
		if len(s) == 1:
			print(n)
		else:
			print(1)
except:
	pass


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print((n, 1)[len({*a}) > 1])


t = int(input(''))
arr = []
for i in range(t):
	int(input(''))
	arr.append(list(map(int, input().split())))
for i in arr:
	n = len(i)
	j = 0
	flag = 0
	i.sort()
	for j in range(len(i) - 1):
		if i[j] != i[j + 1]:
			flag = 1
			break
	if flag:
		print(1)
	else:
		print(len(i))


testCases = int(input())
lst = []
for i in range(testCases):
	n = int(input())
	lst.append(list(map(str, input().split(' '))))
for i in lst:
	if i.count(max(i)) == len(i):
		print(len(i))
	else:
		print(1)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for i in range(Int()):
		n = Int()
		a = List()
		if len(set(a)) == 1:
			print(n)
		else:
			print(1)
solution()


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
for _ in range(II()):
	n = II()
	a = set(MI())
	print(1 if len(a) != 1 else n)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(input().split())
	if a[0] * n == ''.join(a):
		print(n)
	else:
		print(1)


T = int(input())
for test in range(T):
	n = int(input())
	a = [int(x) for x in input().split()]
	uniel = set(a)
	if len(uniel) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for z in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	if li.count(li[0]) == n:
		print(n)
	else:
		print(1)


t = int(input())
while t != 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	count = 0
	for i in range(len(a)):
		if a[i] == a[0]:
			count += 1
	if count == n:
		print(n)
	else:
		print(1)
	t -= 1


II = lambda : list(map(int, input().split()))
for i in range(int(input())):
	(n,) = II()
	A = II()
	if A.count(A[0]) == n:
		print(n)
	else:
		print(1)


t = int(input())
for tt in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	ok = False
	for i in range(1, n):
		if a[i] != a[i - 1]:
			ok = True
	if ok:
		print(1)
	else:
		print(n)


ls = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input()
r = lambda a: range(a)
lcm = lambda a, b: abs(a * b) // math.gcd(a, b)
t = ip()
for _ in r(t):
	digits = ip()
	password = ls()
	pas = sorted(password)
	if pas[0] == pas[-1]:
		print(len(password))
	else:
		print(1)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		flag = 0
		for x in range(n - 1):
			if l[x] != l[x + 1]:
				flag = 1
				break
		if flag == 1:
			print(1)
		else:
			print(n)
	except:
		pass
M = 998244353
P = 1000000007
Inf = 1000000000000000000
for _ in range(I()):
	main()


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	prev = a[0]
	distinct = False
	for i in range(1, n):
		if a[i] != prev:
			distinct = True
			break
	if distinct:
		print(1)
	else:
		print(n)


def solve(A, n):
	res = n
	for i in range(1, n, 1):
		if A[i] != A[i - 1]:
			res = 1
	return res
res = []
t = int(input())
while t:
	n = int(input())
	arr = input().split(' ')
	A = [int(n) for n in arr]
	res.append(solve(A, n))
	t -= 1
for r in res:
	print(r)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		n = I()
		arr = L()
		if len(list(set(arr))) == 1:
			print(n)
		else:
			print(1)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	if max(inp) == min(inp):
		print(len(inp))
		continue
	else:
		print(1)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	b = max(a)
	if sum((x != b for x in a)):
		print(1)
	else:
		print(n)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	N = int(input())
	A = alele()
	if len(set(A)) == 1:
		print(N)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	hashmap = dict()
	for i in range(n):
		hashmap[arr[i]] = hashmap.get(arr[i], 0) + 1
	if len(hashmap) > 1:
		print(1)
	else:
		print(n)


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	m = max(arr)
	for i in range(n):
		if arr[i] != m:
			print(1)
			return
	print(n)
for _ in range(int(input())):
	main()


t = int(input())
for aaa in range(t):
	n = int(input())
	a = [int(xx) for xx in input().split()]
	r = True
	for i in range(n):
		if i == 0:
			k = a[0]
		elif a[i] != k:
			r = False
			break
	if r == True:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, str(input().strip()).split(' ')))
	if n == 1:
		print(1)
	else:
		k = A[0]
		flag = 0
		for i in range(1, len(A)):
			if A[i] != k:
				flag = 1
				break
		if flag == 0:
			print(len(A))
		else:
			print(1)


def fast(arr):
	if len(set(arr)) == 1:
		return len(arr)
	return 1

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		result = fast(arr)
		print(result)
main()


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	b = set(ar)
	if len(b) == 1:
		print(n)
	else:
		print(1)


import collections
t = int(input())
for ti in range(t):
	n = int(input())
	arr = [int(num) for num in input().split()]
	counter = collections.Counter(arr)
	if len(counter) == 1:
		print(len(arr))
	else:
		print(1)


from math import ceil, sqrt

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		values = list(map(int, input().split()))
		s = True
		for i in range(1, n):
			if values[i] != values[i - 1]:
				s = False
		if s:
			print(n)
		else:
			print(1)
main()


from collections import deque
from math import *
import heapq
from random import *
import sys
from copy import deepcopy
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if l == [l[0]] * len(l):
		print(n)
	else:
		print(1)


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	if len(set(s)) == 1:
		print(n)
	else:
		print(1)


for t in range(int(input())):
	n = int(input())
	aa = list(map(int, input().split(' ')))
	f = aa[0]
	eq = all((v == f for v in aa))
	if eq:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 0
	if len(d) == 1:
		print(n)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	x = 0
	l = list(map(int, input().split()))
	c = []
	for i in l:
		if i == l[0]:
			c.append(i)
	if len(c) != n:
		print(1)
	else:
		print(n)


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		if len(set(a)) == 1:
			print(n)
		else:
			print(1)

def B():
	t = int(input())
	for _ in range(t):
		print(0)

def C():
	t = int(input())
	for _ in range(t):
		print(0)

def D():
	t = int(input())
	for _ in range(t):
		print(0)
A()


q = int(input())
while q:
	q -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	if a.count(a[0]) == len(a):
		print(len(a))
	else:
		print(1)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	flag = True
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			flag = False
	if flag:
		print(n)
	else:
		print('1')
	t -= 1


def solve(li):
	li.sort()
	print(len(li)) if li[0] == li[len(li) - 1] else print(1)
for i in range(int(input())):
	n = int(input())
	li = [int(x) for x in input().split()]
	solve(li)


import sys

def check(iterator):
	iterator = iter(iterator)
	try:
		first = next(iterator)
	except StopIteration:
		return True
	return all((first == rest for rest in iterator))
n = int(input())
answers = []
for i in range(n):
	k = int(input())
	a = [int(j) for j in input().split()]
	if check(a):
		answers.append(k)
	else:
		answers.append(1)
for i in answers:
	print(i)


t = int(input())
while t > 0:
	n = int(input())
	ara = list(map(int, input().split()))
	if ara.count(ara[0]) == n:
		print(n)
	else:
		print(1)
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	xs = [int(x) for x in input().split()]
	if len(set(xs)) == 1:
		print(len(xs))
	else:
		print(1)


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	hashi = dict()
	for i in li:
		hashi[i] = 1
	if len(hashi) == 1:
		print(n)
	else:
		print(1)


from collections import defaultdict as dd
import math
import sys
import string
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))

def solve():
	n = nn()
	nums = lm()
	c = nums[0]
	for num in nums:
		if not num == c:
			print(1)
			return
	print(n)
	return
q = nn()
for _ in range(q):
	solve()


for _ in range(int(input())):
	op = int(input())
	lst = list(map(int, input().split(' ')))
	if len(set(lst)) > 1:
		if op < len(lst):
			print(len(lst) - op)
		else:
			print(1)
	else:
		print(len(lst))


import math
from collections import *
import sys
from functools import reduce
import time
from itertools import groupby

def input():
	return sys.stdin.readline()

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
for _test_ in range(int(input())):
	n = int(input())
	li = get_list()
	if len(set(li)) == 1:
		print(n)
	else:
		print(1)


from queue import Queue

def rn():
	a = int(input())
	return a

def rl():
	a = list(map(int, input().split()))
	return a
for _ in range(rn()):
	n = rn()
	a = rl()
	c = 0
	for i in range(1, n):
		if a[i] != a[0]:
			c += 1
	if c == 0:
		print(n)
	else:
		print(1)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	dict = {}
	for el in a:
		if el not in dict:
			dict[el] = 1
		else:
			dict[el] += 1
	if len(dict) >= 2:
		print(1)
	else:
		print(dict.popitem()[1])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	if arr.count(arr[0]) == n:
		print(n)
	else:
		print(1)


t = int(input())
for test in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 0
	for i in range(n - 1):
		if l[i] != l[i + 1]:
			flag = 1
	if flag == 1:
		print(1)
	else:
		print(n)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	flag = 0
	max1 = max(lis)
	for i in lis:
		if i != max1:
			flag = 1
			break
	if flag == 1:
		print(1)
	else:
		print(len(lis))


import bisect
import functools
import itertools
import math
import heapq
import random

def repeat(_func=None, *, times=1):

	def decorator(func):

		@functools.wraps(func)
		def wrapper(*args, **kwargs):
			for _ in range(times):
				func(*args, **kwargs)
		return wrapper
	if _func is None:
		return decorator
	else:
		return decorator(_func)

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
	return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):
	return [int(input()) for _ in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def counter(a):
	d = {}
	for x in a:
		d[x] = d.get(x, 0) + 1
	return d

def factor(n):
	d = {}
	while not n % 2:
		d[2] = d.get(2, 0) + 1
		n //= 2
	i = 3
	while i * i <= n:
		while not n % i:
			d[i] = d.get(i, 0) + 1
			n //= i
		i += 2
	if n > 1:
		d[n] = d.get(n, 0) + 1
	return d

def compare(a, b):
	print(a, b)
	(n, m) = (len(a), len(b))
	(i, j) = (0, 0)
	flag = True
	while flag:
		flag = False
		if a[i] == b[j]:
			if i < n - 1:
				i += 1
				flag = True
			if j < m - 1:
				j += 1
				flag = True
			continue
		return a[i] < b[j]
	return a[i] < b[j]

@repeat(times=getint())
def main():
	n = getint()
	a = set(l_unpack())
	print(1 if len(a) > 1 else n)
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		arry = list(map(int, input().split()))
		ans = False
		for i in range(n - 1):
			if arry[i + 1] != arry[i]:
				ans = True
		yield (1 if ans else n)
t = int(input())
ans = gift()
print(*ans, sep='\n')


cases = int(input())
for i in range(cases):
	n = int(input())
	l2 = input().split(' ')
	arr = []
	for a in l2:
		arr.append(int(a))
	ma = max(arr)
	pos = False
	for j in range(n - 1):
		n1 = arr[j]
		n2 = arr[j + 1]
		if n1 != n2 and n1 + n2 > ma:
			print(1)
			pos = True
			break
	if not pos:
		print(len(arr))


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	if len(list(set(l))) == 1:
		print(len(l))
	else:
		print(1)
t = int(input())
for i in range(t):
	solve()


from sys import stdin, stdout
from math import gcd, sqrt, factorial
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = sorted(R())
	if a[0] == a[-1]:
		print(n)
	else:
		print(1)


def same(n, a):
	w = a[0]
	l = 0
	for k in range(1, n):
		if w != a[k]:
			print(1)
			l = 1
			break
	if l != 1:
		print(n)
t = int(input())
for w in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	same(n, a)


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
mod = 10 ** 9 + 7
while t > 0:
	t -= 1
	n = fi()
	a = li()
	if len(set(a)) == 1:
		print(n)
	else:
		print(1)


def main():
	(n,) = map(int, input().split(' '))
	a = [int(x) for x in input().split(' ')]
	if max(a) == min(a):
		return n
	else:
		return 1
for _ in range(int(input())):
	print(main())


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	iseq = True
	for i in range(1, n):
		if a[i] != a[i - 1]:
			iseq = False
	if iseq:
		print(n)
	else:
		print(1)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if max(a) == min(a):
		print(len(a))
	else:
		print(1)