package main
import (
"bufio"
"fmt"
"math"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var t_cases int
fmt.Fscan(reader, &t_cases)
for t_idx := 0; t_idx < t_cases; t_idx++ {
var n int
fmt.Fscan(reader, &n)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Fscan(reader, &a[i])
}
for {
hasZero := false
for i := 0; i < n; i++ {
if a[i] == 0 {
hasZero = true
break
}
}
maxLen := 0
if hasZero {
curLen := 0
for i := 0; i < 2*n; i++ {
if a[i%n] > 0 {
curLen++
if curLen > maxLen {
maxLen = curLen
}
} else {
curLen = 0
}
}
}
if hasZero && maxLen <= 3 {
break
}
for i := 0; i < n; i++ {
if a[i] > 0 {
next := (i + 1) % n
a[next] -= a[i]
if a[next] < 0 {
a[next] = 0
}
}
}
}
startIndex := -1
for i := 0; i < n; i++ {
if a[i] == 0 {
startIndex = i
break
}
}
if startIndex != -1 {
var blocks [][]int
var currentBlock []int
for i := 0; i < n; i++ {
idx := (startIndex + i) % n
if a[idx] > 0 {
currentBlock = append(currentBlock, idx)
} else {
if len(currentBlock) > 0 {
blocks = append(blocks, currentBlock)
currentBlock = nil
}
}
}
if len(currentBlock) > 0 {
blocks = append(blocks, currentBlock)
}
for _, b := range blocks {
if len(b) == 1 {
continue
} else if len(b) == 2 {
x_idx := b[0]
y_idx := b[1]
if a[x_idx] > 0 {
a[y_idx] %= a[x_idx]
}
} else if len(b) == 3 {
x_idx := b[0]
y_idx := b[1]
z_idx := b[2]
x := int64(a[x_idx])
y := int64(a[y_idx])
z := int64(a[z_idx])
if x == 0 {
continue
}
t := (y + x - 1) / x
delta := float64(x-2*y)*float64(x-2*y) - 8*float64(x)*float64(z)
if delta >= 0 {
root := (float64(2*y-x) - math.Sqrt(delta)) / float64(2*x)
if root > 0 {
t_z := int64(root)
for test_t := t_z - 2; test_t <= t_z+2; test_t++ {
if test_t >= 1 {
val := x*test_t*test_t + (x-2*y)*test_t + 2*z
if val <= 0 {
if test_t < t {
t = test_t
}
break
}
}
}
}
}
sumT := (t * (t + 1)) / 2
new_z := z - t*y + x*sumT
if new_z < 0 {
new_z = 0
}
new_y := y - t*x
if new_y < 0 {
new_y = 0
}
a[y_idx] = int(new_y)
a[z_idx] = int(new_z)
if a[y_idx] > 0 && a[z_idx] == 0 {
a[y_idx] %= a[x_idx]
}
}
}
}
var ans []int
for i := 0; i < n; i++ {
if a[i] > 0 {
ans = append(ans, i+1)
}
}
fmt.Fprintln(writer, len(ans))
if len(ans) > 0 {
for i, val := range ans {
if i > 0 {
fmt.Fprint(writer, " ")
}
fmt.Fprint(writer, val)
}
fmt.Fprintln(writer)
}
}
}