package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n, m int
		fmt.Scan(&n)
		var nums []int
		count := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Scan(&m)
			nums = append(nums, m)
			count[m]++
		}
		var a, b int
		for _, v := range count {
			if v%2 == 1 {
				a++
			} else {
				b++
			}
		}
		if b%2 == 0 {
			fmt.Println(a + b)
		} else {
			fmt.Println(a + b - 1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
	a      []int
)

func solve(n int, a []int) int {
	var b = make(map[int]int)
	for _, x := range a {
		b[x]++
	}
	var dup int
	for _, y := range b {
		dup += y - 1
	}
	return n - dup - dup%2
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a = make([]int, n)
		for i := range a {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var in = bufio.NewReader(os.Stdin)

func readInt() int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine() []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	values := strings.Split(line, " ")
	return values
}

func readArrInt() []int {
	line := readLine()
	res := make([]int, 0, 0)
	for i := range line {
		var x, _ = strconv.Atoi(line[i])
		res = append(res, x)
	}
	return res
}

func main() {
	test := readInt()
	for ; 0 < test; test-- {
		var n = readInt()
		var a = readArrInt()
		var hs map[int]int
		hs = make(map[int]int)
		for i := range a {
			hs[a[i]]++
		}
		res := len(hs)
		if (n - res) % 2 == 1 {
			res--
		}
		fmt.Printf("%d\n", res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()

	var Q int
	fmt.Fscan(reader, &Q)

	const MAX_VALUE int = 10000

	for ; Q > 0; Q-- {
		var n int
		fmt.Fscan(reader, &n)
		cnt := make([]int, MAX_VALUE+2)
		for i := 1; i <= n; i++ {
			var val int
			fmt.Fscan(reader, &val)
			cnt[val] += 1
		}

		var even, odd = 0, 0

		for i := 1; i <= MAX_VALUE; i++ {
			if cnt[i] > 0 {
				if cnt[i]%2 == 0 {
					even += 1
				} else {
					odd += 1
				}
			}
		}
		if even%2 == 1 {
			even -= 1
		}
		fmt.Fprintf(writer, "%d\n", even+odd)
	}
}

package main

import "fmt"

func main() {
	var t, n, temp, count int
	var arr [10007]int
	// fmt.Println(arr)
	fmt.Scan(&t)
	for i := 1; i <= t; i++ {
		count = 0
		fmt.Scan(&n)
		for j := 1; j <= n; j++ {
			fmt.Scan(&temp)
			if arr[temp] != i {
				arr[temp] = i
				count++
			}
			// fmt.Println(arr)
		}
		if (n-count)%2 != 0 {
			count--
		}
		fmt.Println(count)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	MaxInt32 = 1 << 31 - 1
)

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(cin, &n)
		m := map[int]bool{}
		for j := 0; j < n; j++ {
			var a int
			fmt.Fscan(cin, &a)
			m[a] = true
		}
		if (len(m) + n) % 2 == 0 {
			// same parity
			fmt.Println(len(m))
		}else {
			fmt.Println(len(m) - 1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {

		res := make(map[int]int)
		var n, x, l, z int
		fmt.Fscan(in, &n)

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &x)
			res[x] = (res[x] + 1) % 2
		}
		for _, v := range res {
			if v > 0 {
				l++
			} else {
				z++
			}
		}
		fmt.Fprintln(out, l+z/2*2)
	}
}

package main

import (
	"fmt"
	"bufio"
	"os"
)
var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(r,&n)
	a := make([]int,n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r,&a[i])
	}
	mp := map[int]int{}

	for i := 0; i < n; i++ {
		mp[a[i]]++
	}
	cnt := len(mp)
	if (n-cnt) % 2 == 0 {
		fmt.Fprintln(w,cnt)
	} else {
		fmt.Fprintln(w,cnt-1)

	}

}

func main() {
	defer w.Flush()
	var T int
	fmt.Fscan(r,&T)
	for i := 0; i < T; i++ {
		slove()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(r io.Reader, w io.Writer) {
	var t int
	var n int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n)
		var a = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(a)
		fmt.Fprintln(w, w1)
	}
}

func do(a []int) int {
	m := map[int]int{}
	for _, v := range a {
		m[v]++
	}
	c := 0
	d := 0
	for _, v := range m {
		if v%2 == 1 {
			c++
		} else {
			d++
		}
	}
	if d%2 == 1 {
		d--
	}
	return c + d
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)
		mp := make(map[int]int)
		nums := make([]int, n)

		var a int
		for i := 0; i < n; i++ {
			Fscan(in, &a)
			nums[i] = a
			mp[a]++
		}

		for i := 0; i < n; i++ {
			if mp[nums[i]] > 1 {
				removed := false
				for j := i + 1; j < n; j++ {
					if mp[nums[j]] > 1 && nums[i] != nums[j] {
						mp[nums[i]]--
						mp[nums[j]]--
						nums[i] = -1
						nums[j] = -1
						removed = true
						break
					}
				}
				if !removed {
					for j := i + 1; j < n; j++ {
						if mp[nums[j]] > 1 && nums[i] == nums[j] {
							mp[nums[i]]--
							mp[nums[j]]--
							nums[i] = -1
							nums[j] = -1
							break
						}
					}
				}
			}
		}

		cnt := 0
		for i := 0; i < n; i++ {
			if nums[i] != -1 {
				cnt++
			}
		}

		Fprintln(out, cnt)

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	var values = make(map[int]bool, n)
	var tmp int
	var res int
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &tmp)
		if !values[tmp] {
			values[tmp] = true
		}
	}

	res = len(values)
	if (n-res)%2 == 1 {
		res--
	}

	return strconv.FormatInt(int64(res), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	numToCnt := make(map[int]int)

	for i := range a {
		scanf("%d", &a[i])

		numToCnt[a[i]]++
	}
	scanf("\n")

	removeCnt := 0

	for _, cnt := range numToCnt {
		removeCnt += cnt - 1
	}

	if removeCnt%2 != 0 {
		removeCnt++
	}

	fmt.Fprintln(writer, n-removeCnt)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int64) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"runtime/debug"
)

/* begin of MyIO */
const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false
	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO

func ri() int {
	return myio.ReadInt()
}

func ri64() int64 {
	return myio.ReadInt64()
}

func ria(_n int) []int {
	a := make([]int, _n)
	for i := range a {
		a[i] = ri()
	}
	return a
}

/* End of MyIO */

func sol() {
	n := ri()
	a := ria(n)
	m := make(map[int]bool)
	c := 0
	for i := 0; i < n; i++ {
		if _, ok := m[a[i]]; !ok {
			m[a[i]] = true
			c += 1
		}
	}
	z := n - c
	if z%2 == 1 {
		myio.Println(c - 1)
	} else {
		myio.Println(c)
	}
}

func main() {
	debug.SetGCPercent(-1)
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()

	var t = 1
	t = ri()
	for ; t > 0; t-- {
		sol()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	cnt := map[int]int{}
	ans := len(nums)
	for i := range nums {
		cnt[nums[i]]++
	}
	out := len(cnt)
	if (ans - out) % 2 == 0 {
		fmt.Fprintln(w, out)
	} else {
		fmt.Fprintln(w, out-1)
	}

}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// https://space.bilibili.com/206214/dynamic
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		cnt := map[int]int{}
		for _, v := range a {
			cnt[v]++
		}
		rm := 0
		for _, c := range cnt {
			rm+=c-1
		}
		if rm&1==1 {
			rm++
		}
		Fprintln(out, n-rm)
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

func main() { run(os.Stdin, os.Stdout) }

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		counter:=1
		for j:=1;j<len(list);j++{
			if list[j] != list[j-1] {
				counter++
			}
		}
		if (n%2 == 0 && counter % 2 == 0) || (n%2 != 0 && counter % 2 != 0) {
			fmt.Println(counter)
		} else {
			fmt.Println(counter-1)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	_, _ = fmt.Fscan(r, &n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Fscan(r, &lenSlice)

		slice := make([]int, lenSlice)
		for i := 0; i < lenSlice; i++ {
			_, _ = fmt.Fscan(r, &slice[i])
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int

		if (lenSlice-cantUniq)%2 == 0 {
			result = cantUniq
		} else {
			result = cantUniq - 1
		}

		_, _ = fmt.Fprintln(w, result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, lenSlice)
		for i := 0; i < lenSlice; i++ {
			_, _ = fmt.Scan(&slice[i])
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int

		if (lenSlice-cantUniq)%2 == 0 {
			result = cantUniq
		} else {
			result = cantUniq - 1
		}

		fmt.Println(result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, lenSlice)
		for i := 0; i < lenSlice; i++ {
			_, _ = fmt.Scan(&slice[i])
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int
		if cantUniq == lenSlice {
			result = lenSlice
		} else if lenSlice%2 == 0 && cantUniq%2 == 0 {
			result = cantUniq
		} else if lenSlice%2 != 0 && cantUniq%2 != 0 {
			result = cantUniq
		} else {
			result = cantUniq - 1
		}

		fmt.Println(result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, 0)
		for i := 0; i < lenSlice; i++ {
			var val int
			_, _ = fmt.Scan(&val)

			slice = append(slice, val)
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int
		if cantUniq == lenSlice {
			result = lenSlice
		} else if lenSlice%2 == 0 && cantUniq%2 == 0 {
			result = cantUniq
		} else if lenSlice%2 != 0 && cantUniq%2 != 0 {
			result = cantUniq
		} else {
			result = cantUniq - 1
		}

		fmt.Println(result)
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		m := make(map[int]int)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			m[v]++
		}

		tot := len(m)
		if (n-len(m))%2 > 0 {
			tot--
		}
		fmt.Fprintln(out, tot)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		m := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
			m[a[i]]++
		}
		if (n-len(m))%2 > 0 {
			fmt.Fprintln(out, len(m)-1)
		} else {
			fmt.Fprintln(out, len(m))
		}
	}
}

package main

import (
  "fmt"
  "sort"
)

func main() {
	var t int
	fmt.Scan(&t)

	for k:=0;k<t;k++{
	    ans := 0
	    var num int
	    mal := []int{}
	    fmt.Scan(&num)
	    for j:=0;j<num;j++{
	        var hui int
	        fmt.Scan(&hui)
	        mal = append(mal,hui)
	    }
	    sort.Ints(mal)

	    for i:= 1; i<len(mal);i++ {
	        if mal[i-1]==mal[i]{
	            ans++
	        }
	    }

	    if ans%2==1{
	        ans++
	    }

	    fmt.Println(len(mal)-ans)

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n,t,a int
	ans := 0
	//kisu := 0
	//guusuu := 0
	//count:= 0
	fmt.Fscan(in, &n)

	// bitsがn個の要素の各パターンを表す
	for i := 0;i < n;i++ {
		fmt.Fscan(in, &t)
		m := make(map[int]int)
		//list := make([]int,t)
		for j := 0;j < t;j++ {
			fmt.Fscan(in, &a)
			if _,ok := m[a];ok{
				m[a]++
				ans++
			}else{
				m[a] = 1
				ans++
				//list[count] = a
				//count++
			}
		}
		//for j := 0;j < len(m);j++ {
		//	if m[list[j]]%2 == 1{
		//		kisu++
		//	}else{
		//		guusuu++
		//	}
		//}
		//fmt.Println(len(m))
		if (ans-len(m))%2 == 1{
			fmt.Println(len(m)-1)
		}else{
			fmt.Println(len(m))
		}

		ans = 0
		//kisu = 0
		//guusuu = 0
		//count = 0
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader *bufio.Reader = bufio.NewReader(os.Stdin)
	writer *bufio.Writer = bufio.NewWriter(os.Stdout)
	debug                = fmt.Println
)

func solve() {
	var n int
	scanf("%d\n", &n)
	arr := IntArray(n)

	mp := map[int]int{}
	s := 0
	for i := range arr {
		if _, found := mp[arr[i]]; found {
			s += 1
		} else {
			mp[arr[i]] = 1
		}
	}

	if s%2 == 0 {
		n -= s
	} else {
		n -= (s + 1)
	}

	printf("%v\n", n)
}

func main() {
	defer writer.Flush()

	var cases int

	scanf("%d\n", &cases)
	// cases = 1

	for c := 0; c < cases; c++ {
		solve()
	}
}

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func IntArray(size int) []int {
	arr := make([]int, size)
	for i := 0; i < size; i++ {
		scanf("%d", &arr[i])
	}
	scanf("\n")
	return arr
}

func Max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func Min(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] < m {
			m = args[i]
		}
	}
	return m
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1692B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1692B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1692B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1692B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1692B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1692B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1692B
Date: 18/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1692/B
Problem: CF1692B
**/
func (in *CF1692B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[int]bool)
		count := 0
		for i := 0; i < n; i++ {
			val := in.NextInt()
			if _, exist := mapa[val]; !exist {
				mapa[val] = true
			} else {
				count++
			}
		}
		if count%2 != 0 {
			fmt.Println(n - count - 1)
		} else {
			fmt.Println(n - count)
		}

	}
}

func NewCF1692B(r *bufio.Reader) *CF1692B {
	return &CF1692B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1692B(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func out(x ...interface{}) {
	fmt.Fprint(wr, x...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	defer wr.Flush()
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

	t := nextInt()
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	n := nextInt()
	mp := make(map[int]bool)
	for i := 0; i < n; i++ {
		a := nextInt()
		mp[a] = true
	}
	ans := len(mp) - ((len(mp) - n) & 1)

	out(ans, "\n")
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		for j:=1;j<len(list);j++{
			if list[j] == list[j-1] {
				list = append(list[:j-1],list[j:len(list)-1]...)
				j--
			}
		}
		fmt.Println(len(list))
	}
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		counter:=0
		for j:=1;j<len(list);j++{ // iterate over each element
			if len(list) == 2 && list[j] == list[j-1] && counter>0 {
				break
			}
			if list[j] == list[j-1] {
				counter++
				list = append(list[:j-1],list[j:len(list)-1]...)
				j--
			}
		}
		fmt.Println(len(list))
	}
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		for j:=1;j<len(list);j++{ // iterate over each element
			if len(list) == 2 && list[j] == list[j-1] {
				break
			}
			if list[j] == list[j-1] {
				list = append(list[:j-1],list[j:len(list)-1]...)
				j--
			}
		}
		fmt.Println(len(list))
	}
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		for j:=1;j<len(list);j++{ // iterate over each element
			if list[j] == list[j-1] {
				list = append(list[:j-1],list[j:len(list)-1]...)
				j--
			}
		}
		fmt.Println(len(list))
	}
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		counter:=1
		for j:=1;j<len(list);j++{ // iterate over each element
			if list[j-1] == list[j] {
				counter++
				if counter >= 3 {
					list = append(list[:j-2],list[j:]...)
					j-=2
					counter=1
				} else if j == len(list)-1 {
					if counter >= 2 {
						list= list[:len(list)-2]
					}
				}
			} else if list[j-1] != list[j] {
				if counter >= 2 {
					list = append(list[:j-1],list[j:]...)
					list = list[:len(list)-1]
					j--
					counter=1
				}
			}
		}
		fmt.Println(len(list))
	}
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		counter:=1
		for j:=1;j<len(list);j++{ // iterate over each element
			if list[j-1] == list[j] {
				counter++
				if counter >= 3 {
					list = append(list[:j-2],list[j:]...)
					j--
					counter=1
				} else if j == len(list)-1 {
					if counter >= 2 {
						list= list[:len(list)-2]
					}
				}
			} else if list[j-1] != list[j] {
				if counter >= 2 {
					list = append(list[:j-1],list[j:]...)
					list = list[:len(list)-1]
					j--
					counter=1
				}
			}
		}
		fmt.Println(len(list))
	}
}

package main
import(
    "fmt"
    "sort"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
		}
		sort.Ints(list)
		for j:=0;j<len(list)-1;j++{ // iterate over each element
			if list[j] == list[j+1] {
				for k:=0;k<len(list);k++{ // search for other
					if list[k] != list[j] {
						list= append(list[:k],list[k+1:]...)
						list= append(list[:j],list[j+1:]...)
						break
					}
				}
			}
		}
		fmt.Println(len(list))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {

	var n int
	_, _ = fmt.Fscan(r, &n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Fscan(r, &lenSlice)

		slice := make([]int, lenSlice)
		for i := 0; i < lenSlice; i++ {
			_, _ = fmt.Fscan(r, &slice[i])
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int

		if (lenSlice-cantUniq)%2 == 0 {
			result = cantUniq
		} else {
			result = cantUniq - 1
		}

		_, _ = fmt.Fprintln(w, result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, 0)
		for i := 0; i < lenSlice; i++ {
			var val int
			_, _ = fmt.Scan(&val)

			slice = append(slice, val)
		}

		if lenSlice == 1 {
			println(1)
			continue
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int
		if cantUniq == lenSlice {
			result = lenSlice
		} else if lenSlice%2 == 0 && cantUniq%2 == 0 {
			result = cantUniq
		} else {
			result = cantUniq - 1
		}

		fmt.Println(result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, 0)
		for i := 0; i < lenSlice; i++ {
			var val int
			_, _ = fmt.Scan(&val)

			slice = append(slice, val)
		}

		if lenSlice == 1 {
			println(1)
			continue
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int
		if lenSlice%2 == 0 {
			if cantUniq%2 == 0 {
				result = cantUniq
			}
		} else {
			result = cantUniq - 1
		}

		fmt.Println(result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, 0)
		for i := 0; i < lenSlice; i++ {
			var val int
			_, _ = fmt.Scan(&val)

			slice = append(slice, val)
		}

		if lenSlice == 1 {
			println(1)
			continue
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		var result int
		if lenSlice%2 == 0 {
			if cantUniq%2 == 0 {
				result = cantUniq
			}
		} else {
			fmt.Println(cantUniq - 1)
		}

		fmt.Println(result)
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, 0)
		for i := 0; i < lenSlice; i++ {
			var val int
			_, _ = fmt.Scan(&val)

			slice = append(slice, val)
		}

		if lenSlice == 1 {
			println(1)
			continue
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		if lenSlice%2 == 0 {
			fmt.Println(cantUniq)
		} else {
			fmt.Println(cantUniq - 1)
		}
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	_, _ = fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var lenSlice int
		_, _ = fmt.Scan(&lenSlice)

		slice := make([]int, 0)
		for i := 0; i < lenSlice; i++ {
			var val int
			_, _ = fmt.Scan(&val)

			slice = append(slice, val)
		}

		if lenSlice == 1 {
			println(1)
			continue
		}

		uniques := make(map[int]int)
		for _, s := range slice {
			uniques[s]++
		}

		cantUniq := len(uniques)
		if lenSlice%2 == 0 {
			println(cantUniq)
		} else {
			println(cantUniq - 1)
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		m := make([]int, 10002)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			m[v]++
		}

		sort.Slice(m, func(i, j int) bool {
			return m[i] > m[j]
		})
		c := m[0] - 1
		m[0] = 1
		for i := 1; i < 10002; i++ {
			if m[i] == 0 {
				break
			}
			d := min(c, m[i])
			m[i] -= d
			c -= d
		}

		var tot int
		for _, v := range m {
			if v > 0 {
				tot++
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		m := make(map[int]int)
		var max int
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			m[v]++
			if m[v] > max {
				max = m[v]
			}
		}

		var tot int
		for _, v := range m {
			if v == max {
				tot++
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n,t,a int
	//ans := 0
	kisu := 0
	guusuu := 0
	count:= 0
	fmt.Fscan(in, &n)

	// bitsがn個の要素の各パターンを表す
	for i := 0;i < n;i++ {
		fmt.Fscan(in, &t)
		m := make(map[int]int)
		list := make([]int,t)
		for j := 0;j < t;j++ {
			fmt.Fscan(in, &a)
			if _,ok := m[a];ok{
				m[a]++
			}else{
				m[a] = 1
				list[count] = a
				count++
			}
		}
		for j := 0;j < len(m);j++ {
			if m[list[j]]%2 == 1{
				kisu++
			}else{
				guusuu++
			}
		}

		if kisu > 0{
			fmt.Println(kisu)
		}else if len(m) == 1{
			fmt.Println(0)
		}else if len(m)%2 == 1{
			fmt.Println(guusuu-1)
		}else{
			fmt.Println(guusuu)
		}

		//ans = 0
		kisu = 0
		guusuu = 0
		count = 0
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n,t,a int
	//ans := 0
	kisu := 0
	guusuu := 0
	count:= 0
	fmt.Fscan(in, &n)

	// bitsがn個の要素の各パターンを表す
	for i := 0;i < n;i++ {
		fmt.Fscan(in, &t)
		m := make(map[int]int)
		list := make([]int,t)
		for j := 0;j < t;j++ {
			fmt.Fscan(in, &a)
			if _,ok := m[a];ok{
				m[a]++
			}else{
				m[a] = 1
				list[count] = a
				count++
			}
		}
		for j := 0;j < len(m);j++ {
			if m[list[j]]%2 == 1{
				kisu++
			}else{
				guusuu++
			}
		}

		if kisu > 0{
			fmt.Println(kisu)
		}else if len(m) == 1{
			fmt.Println(0)
		}else{
			fmt.Println(guusuu)
		}

		//ans = 0
		kisu = 0
		guusuu = 0
		count = 0
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n,t,a int
	//ans := 0
	kisu := 0
	guusuu := 0
	count:= 0
	fmt.Fscan(in, &n)

	// bitsがn個の要素の各パターンを表す
	for i := 0;i < n;i++ {
		fmt.Fscan(in, &t)
		m := make(map[int]int)
		list := make([]int,t)
		for j := 0;j < t;j++ {
			fmt.Fscan(in, &a)
			if _,ok := m[a];ok{
				m[a]++
			}else{
				m[a] = 1
				list[count] = a
				count++
			}
		}
		for j := 0;j < len(m);j++ {
			if m[list[j]]%2 == 1{
				kisu++
			}else{
				guusuu++
			}
		}

		if kisu > 0{
			fmt.Println(kisu)
		}else{
			fmt.Println(guusuu)
		}

		//ans = 0
		kisu = 0
		guusuu = 0
		count = 0
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader *bufio.Reader = bufio.NewReader(os.Stdin)
	writer *bufio.Writer = bufio.NewWriter(os.Stdout)
	debug                = fmt.Println
)

func solve() {
	var n int
	scanf("%d\n", &n)
	arr := IntArray(n)

	mp := map[int]int{}
	for i := range arr {
		if _, found := mp[arr[i]]; found {
			n -= 1
			mp[arr[i]] += 1
		} else {
			mp[arr[i]] = 1
		}
	}

	preVal := -1
	for _, val := range mp {
		if preVal == -1 {
			preVal = val
			continue
		}
		if val != preVal {
			n -= 1
			break
		}
	}

	printf("%v\n", n)
}

func main() {
	defer writer.Flush()

	var cases int

	scanf("%d\n", &cases)
	// cases = 1

	for c := 0; c < cases; c++ {
		solve()
	}
}

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func IntArray(size int) []int {
	arr := make([]int, size)
	for i := 0; i < size; i++ {
		scanf("%d", &arr[i])
	}
	scanf("\n")
	return arr
}

func Max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func Min(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] < m {
			m = args[i]
		}
	}
	return m
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1692B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1692B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1692B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1692B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1692B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1692B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1692B
Date: 18/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1692/B
Problem: CF1692B
**/
func (in *CF1692B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[int]bool)
		for i:=0;i<n;i++{
			mapa[in.NextInt()] = true
		}
		fmt.Println(len(mapa))

	}
}

func NewCF1692B(r *bufio.Reader) *CF1692B {
	return &CF1692B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1692B(bufio.NewReader(os.Stdin)).Run()
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	d1742(os.Stdin, os.Stdout)
}

func d1742(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var x int

	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		p := make([]int, 1001)
		for i, _ := range p {
			p[i] = -1
		}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			p[x] = i
		}
		ans := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if p[i] >= 0 && p[j] >= 0 {
					if gcd(i, j) == 1 {
						if p[i]+p[j]+2 > ans {
							ans = p[i] + p[j] + 2
						}
					}
				}
			}
		}

		Fprintln(out, ans)
	}
}

package main

import (
	"fmt"
)

func main() {
	var num int
	fmt.Scan(&num)
	for i := 0; i < num; i++ {

		var numArr []int
		var num2 int
		fmt.Scan(&num2)
		for i := 0; i < num2; i++ {

			var num3 int
			fmt.Scan(&num3)
			numArr = append(numArr, num3)
		}
		var res int
		res = four(numArr)
		fmt.Println(res)
		// var res string
		// res = sec(numArr)
	}

}

func four(arr []int) int {
	arrMap := make(map[int]int)

	for i := 0; i < len(arr); i++ {
		arrMap[arr[i]] = i
	}
	max := 0
	for i := 1000; i > 0; i-- {
		for j := i; j > 0; j-- {
			if gcd(i, j) == 1 {
				val1, ok1 := arrMap[i]
				val2, ok2 := arrMap[j]
				if ok1 && ok2 {
					if val1+val2+2 > max {
						max = val1 + val2 + 2
					}
				}
			}
		}
	}
	if max == 0 {
		return -1
	}
	return max
}

func gcd(a, b int) int {
	// 如果分子大于分母，需要交换顺序
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a, b int) int {
	if a > b { return a }
	return b
}

func gcd(a, b int) int {
	if b == 0 { return a }
	return gcd(b, a%b)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var v [][]int
	for i := 1; i <= 1000; i++ {
		for j := i; j <= 1000; j++ {
			if gcd(i, j) == 1 {
				v = append(v, []int{i, j})
			}
		}
	}

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		b := make([]int, 1004)
		for i := range b { b[i] = -3e5 }

		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
			b[a[i]] = max(b[a[i]], i+1)
		}

		res := -1
		for _, vv := range v {
			res = max(res, b[vv[0]] + b[vv[1]])
		}
		fmt.Fprintln(w, res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a, b int) int {
	if a > b { return a }
	return b
}

func gcd(a, b int) int {
	if b == 0 { return a }
	return gcd(b, a%b)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		b := make([]int, 1004)
		for i := range b { b[i] = -3e5 }

		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
			b[a[i]] = max(b[a[i]], i+1)
		}

		res := -1
		for i, v1 := range b {
			for j, v2 := range b {
				if gcd(i, j) == 1 {
					res = max(res, v1 + v2)
				}
			}
		}
		fmt.Fprintln(w, res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a, b int) int {
	if a > b { return a }
	return b
}

func gcd(a, b int) int {
	if b == 0 { return a }
	return gcd(b, a%b)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		b := make([]int, 1004)
		for i := range b { b[i] = -3e5 }

		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)

		for i := range a {
			fmt.Fscan(r, &a[i])
			b[a[i]] = max(b[a[i]], i+1)
		}

		res := -1
		for i, v1 := range b {
			for j, v2 := range b {
				if gcd(i, j) == 1 {
					// fmt.Fprintf(w, "*** i:%d j:%d v1:%d v2:%d v1+v2:%d\n", i, j, v1, v2, v1 + v2) // ***
					res = max(res, v1 + v2)
				}
			}
		}
		fmt.Fprintln(w, res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve() {
	var N, X int

	fmt.Fscan(in, &N)
	a := make([]int, 1001)
	for i := 1; i <= N; i++ {
		fmt.Fscan(in, &X)
		a[X] = i
	}

	result := -1
	for i := 1; i < 1001; i++ {
		for j := i; j < 1001; j++ {
			if a[i] > 0 && a[j] > 0 && a[i]+a[j] > result && gcd(i, j) == 1 {
				result = a[i] + a[j]
			}
		}
	}

	fmt.Fprintln(out, result)
}

func main() {
	var T int
	fmt.Fscan(in, &T)
	for ; T > 0; T-- {
		solve()
	}
	out.Flush()
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func gcd(a, b int) int {
	if b != 0 {
		return gcd(b, a % b)
	}
	return a
}

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		var n int
		Fscan(in, &n)
		var a = [1001]int{}
		for i := 0; i < n; i++ {
			var x int
			Fscan(in, &x)
			a[x] = i + 1
		}
		ans := -1
		for i := 0; i <= 1000; i++ {
			for j := 0; j <= i; j ++ {
				if gcd(i, j) == 1 && a[i] > 0 && a[j] > 0 {
					if ans < a[i] + a[j] {
						ans = a[i] + a[j]
					}
				}
			}
		}
		Fprintln(out, ans)
	}
}

func main() {
	run(os.Stdin, os.Stdout)
}

package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if b != 0 {
		return gcd(b, a % b)
	}
	return a
}

func main() {
	var T int
	fmt.Scan(&T)
	for Case := 1; Case <= T; Case++ {
		var n int
		fmt.Scan(&n)
		var a = [1001]int{}
		for i := 0; i < n; i++ {
			var x int
			fmt.Scan(&x)
			a[x] = i + 1
		}
		ans := -1
		for i := 0; i <= 1000; i++ {
			for j := 0; j <= i; j ++ {
				if gcd(i, j) == 1 && a[i] > 0 && a[j] > 0 {
					if ans < a[i] + a[j] {
						ans = a[i] + a[j]
					}
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
  "os"
)

var in = bufio.NewReader(os.Stdin)

func  gcd(a, b int) int {
  for b != 0 {
      a, b = b, a%b
  }
  return a
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var n int
    fmt.Fscan(in, &n)
    a := make([]int, 1005, 1005)
    for i := 1; i <= n;i++{
      var x int
      fmt.Fscan(in, &x)
      a[x] = i
    }
    ret := -1
    for i := 1; i <= 1000; i++ {
      for j := 1; j <= 1000; j++ {
        if a[i] + a[j] > ret && gcd(i, j) == 1 && a[i] > 0 && a[j] > 0 {
          ret = a[i] + a[j]
        }
      }
    }
    fmt.Println(ret)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		mx := -1
		a := make([]int, n)
		mp := make(map[int]int)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			mp[a[j]] = j
		}
		for v, vid := range mp {
			for vv, vvid := range mp {
				if gcd(v, vv) == 1 {
					mx = max(mx, vid+vvid+2)
				}
			}
		}
		fmt.Println(mx)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func readInt() int {
	var i int
	fmt.Fscan(reader, &i)
	return i
}

func readString() string {
	var s string
	fmt.Fscan(reader, &s)
	return s
}

func max(u int, v int) int {
	if u < v {
		u = v
	}
	return u
}

func gcd(u int, v int) int {
	if u == 0 {
		return v
	}
	return gcd(v % u, u)
}

func main(){
	defer writer.Flush()
	T := readInt()
	for i := 1; i <= T; i++{
		n := readInt()
		m := make([]int, 1001)
		for i := 1; i <= n; i++ {
			a := readInt()
			m[a] = max(m[a], i)
		}
		ans := -1
		for i := 1000; i >= 1; i--{
			if m[i] > 0 {
				for j := i; j > 0; j-- {
					if m[j] == 0 {
						continue
					}
					if gcd(i, j) == 1 {
						ans = max(ans, m[i] + m[j])
					}
				}
			}
		}
		fmt.Fprintln(writer, ans)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

const mod = 998244353
const mx = int64(1e9 + 7)

var crp [][]int

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	Fscan(in, &n)
	arr := make([]int, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &arr[i])
	}
	idx := make([][]int, 1001)
	ans := -1
	for i := 1; i <= n; i++ {
		idx[arr[i]] = append(idx[arr[i]], i)
		for _, v := range crp[arr[i]] {
			if len(idx[v]) != 0 {
				ans = max(i+idx[v][len(idx[v])-1], ans)
			}
		}
	}
	Fprintln(out, ans)
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	crp = make([][]int, 1001)
	for i := 1; i <= 1000; i++ {
		for j := 1; j <= 1000; j++ {
			if gcd(i, j) == 1 {
				crp[i] = append(crp[i], j)
			}
		}
	}
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func gcd(x, y int) int {
	if x < y {
		return gcd(y, x)
	}
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func solve(n int, a []int) int {
	b := make([]int, 1001)
	for i, x := range a {
		b[x] = i + 1
	}
	m := -1
	for i := 1; i < 1001; i++ {
		for j := i; j < 1001; j++ {
			if b[i] > 0 && b[j] > 0 && gcd(i, j) == 1 && b[i]+b[j] > m {
				m = b[i] + b[j]
			}
		}
	}
	return m
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	maxInd := make([]int, 1001)
	for i := range maxInd {
		maxInd[i] = -1
	}
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		maxInd[arr[i]] = i
	}
	ans := -1
	for i := 1; i <= 1000; i++ {
		for j := 1; j <= 1000; j++ {
			if maxInd[i] == -1 || maxInd[j] == -1 || GCD(i, j) != 1 {
				continue
			}
			ans = max(ans, maxInd[i]+maxInd[j]+2)
		}
	}
	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func GCD(a, b int) int {
	for a != b {
		if a > b {
			a -= b
		} else {
			b -= a
		}
	}

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func gcd(a, b int) int {
	for b != 0 {
		a %= b
		a, b = b, a
	}
	return a
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	vz := make([][]int, 1001)
	for i := 1; i <= 1000; i++ {
		for j := 1; j <= i; j++ {
			if gcd(i, j) == 1 {
				vz[i] = append(vz[i], j)
				vz[j] = append(vz[j], i)
			}
		}
	}

	t := io.ReadInt()
	for ; t > 0; t-- {
		n := io.ReadInt()
		a := io.ReadIntSlice(n)

		mx := make([]int, 1001)
		for i := 0; i < len(a); i++ {
			mx[a[i]] = i + 1
		}

		ans := -1

		for i := len(a) - 1; i >= 0; i-- {
			curr := a[i]
			for j := 0; j < len(vz[curr]); j++ {
				nw := mx[vz[curr][j]]
				if nw != 0 {
					ans = max(ans, i+1+nw)
				}
			}
		}

		io.Println(ans)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		pos := [1001]int{}
		for i, v := range a {
			pos[v] = max(pos[v], i+1)
		}
		ans := -1
		for i := 1; i <= 1000; i++ {
			for j := 1; j <= 1000; j++ {
				if gcd(i,j) != 1 {
					continue
				}
				p,q := pos[i],pos[j]
				if p > 0 && q > 0 {
					ans = max(ans, p+q)
				}
			}
		}
		Fprintln(out, ans)
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	// 如果是多组数据，请务必加上这段保险 —— 已经无法统计，有多少位竞赛选手在漏读数据上损失大把分数（包括我）
	// 此外，如果不小心写成了 scan(v) 而不是 scan(&v)，由于未传入指针，不会读入任何数据，这样本地运行一次就能立马发现错误
	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

func main() { run(os.Stdin, os.Stdout) }

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}
func max(a, b int) int {
	if b > a {
		return b
	}
	return a
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1742D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, X int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &N)
		a := make([]int, 1001)
		for i := 1; i <= N; i++ {
			fmt.Fscan(in, &X)
			a[X] = i
		}
		result := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if a[i] > 0 && a[j] > 0 && a[i]+a[j] > result && gcd(i, j) == 1 {
					result = a[i] + a[j]
				}
			}
		}
		fmt.Fprintln(out, result)
	}
}

func gcd(i, j int) int {
	for j != 0 {
		i, j = j, i%j
	}
	return i
}

func main() {
	CF1742D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1742D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &N)
		a, b := make([]int, N+1), make([]int, 1001)
		for i := 1; i <= N; i++ {
			fmt.Fscan(in, &a[i])
			b[a[i]] = i
		}
		result := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if b[i] > 0 && b[j] > 0 && gcd(i, j) == 1 && b[i]+b[j] > result {
					result = b[i] + b[j]
				}
			}
		}
		fmt.Fprintln(out, result)
	}
}

func gcd(i, j int) int {
	for j != 0 {
		i, j = j, i%j
	}
	return i
}

func main() {
	CF1742D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1742D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &N)
		a, b := make([]int, N+1), make([]int, 1001)
		for i := 1; i <= N; i++ {
			fmt.Fscan(in, &a[i])
			b[a[i]] = i
		}
		result := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if b[i] > 0 && b[j] > 0 && gcd(i, j) == 1 && b[i]+b[j] > result {
					result = b[i] + b[j]
				}
			}
		}
		fmt.Fprintln(out, result)
	}
}

func gcd(i, j int) int {
	if j == 0 {
		return i
	}
	return gcd(j, i%j)
}

func main() {
	CF1742D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		aa := make([]int, n)
		for i := range aa {
			fmt.Fscan(in, &aa[i])
		}

		bb := make([]int, 1001)
		for i, v := range aa {
			bb[v] = i + 1
		}

		d := -1
		for i := 1; i <= 1000; i++ {
			if bb[i] == 0 {
				continue
			}
			for j := 1; j <= 1000; j++ {
				if bb[j] == 0 || gcd(i, j) != 1 {
					continue
				}
				d = max(d, bb[i]+bb[j])
			}
		}
		fmt.Fprintln(out, d)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1742D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, X int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &N)
		a := make([]int, 1001)
		for i := 1; i <= N; i++ {
			fmt.Fscan(in, &X)
			a[X] = i
		}
		result := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if a[i]+a[j] > result && gcd(i, j) == 1 {
					result = a[i] + a[j]
				}
			}
		}
		fmt.Fprintln(out, result)
	}
}

func gcd(i, j int) int {
	for j != 0 {
		i, j = j, i%j
	}
	return i
}

func main() {
	CF1742D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1742D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &N)
		a, b := make([]int, N+1), make([]int, 1001)
		for i := 1; i <= N; i++ {
			fmt.Fscan(in, &a[i])
			b[a[i]] = i
		}
		result := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if gcd(i, j) == 1 && b[i]+b[j] > result {
					result = b[i] + b[j]
				}
			}
		}
		fmt.Fprintln(out, result)
	}
}

func gcd(i, j int) int {
	if j == 0 {
		return i
	}
	return gcd(j, i%j)
}

func main() {
	CF1742D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		aa := make([]int, n)
		for i := range aa {
			fmt.Fscan(in, &aa[i])
		}

		bb := make([]int, 1001)
		for i, v := range aa {
			bb[v] = i + 1
		}

		d := -1
		for i := 1; i <= 20; i++ {
			if bb[i] == 0 {
				continue
			}
			for j := 1; j <= 20; j++ {
				if bb[j] == 0 || gcd(i, j) != 1 {
					continue
				}
				d = max(d, bb[i]+bb[j])
			}
		}
		fmt.Fprintln(out, d)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a, b int) int {
	if a > b { return a }
	return b
}

func gcd(a, b int) int {
	if b == 0 { return a }
	return gcd(b, a%b)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		b := make([]int, 1004)
		for i := range b { b[i] = -2e5 }

		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)

		for i := range a {
			fmt.Fscan(r, &a[i])
			b[a[i]] = max(b[a[i]], i+1)
		}

		res := -1
		for i, v1 := range b {
			for j, v2 := range b {
				if gcd(i, j) == 1 {
					res = max(res, v1 + v2)
				}
			}
		}
		fmt.Fprintln(w, res)
	}

}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	d1742(os.Stdin, os.Stdout)
}

func d1742(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var x int

	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		r := make([]int, n)
		p := make([]int, 1001)
		for i, _ := range p {
			p[i] = -1
		}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			r[i] = x
			p[x] = i
		}
		ans := -1
		for i := 1; i < 1001; i++ {
			for j := i; j < 1001; j++ {
				if p[i] > 0 && p[j] > 0 {
					if gcd(i, j) == 1 {
						if p[i]+p[j]+2 > ans {
							ans = p[i] + p[j] + 2
						}
					}
				}
			}
		}

		Fprintln(out, ans)
	}
}