← Home
```go
package main

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

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

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

	for i := 0; i < t; i++ {
		solve(reader, writer)
	}
}

func solve(r *bufio.Reader, w *bufio.Writer) {
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	hasZero := false
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
		if a[i] == 0 {
			hasZero = true
		}
	}

	// Simulate rounds until at least one zero appears.
	// Logic suggests a zero appears within 1 round for any non-trivial case.
	// We bound it safely by 2*n, though it should break much earlier.
	for k := 0; k < 2*n && !hasZero; k++ {
		// One round of attacks
		// Note: The problem states attacks happen sequentially.
		// Since we need to update based on the state at the moment of attack,
		// and the order is 1->2, 2->3... n->1.
		for i := 0; i < n; i++ {
			atk := a[i]
			defIdx := (i + 1) % n
			if a[defIdx] > 0 {
				a[defIdx] -= atk
				if a[defIdx] < 0 {
					a[defIdx] = 0
				}
			}
		}

		// Check for zeros
		for _, v := range a {
			if v == 0 {
				hasZero = true
				break
			}
		}
	}

	// Identify the start of a chain (a zero value)
	offset := -1
	for i := 0; i < n; i++ {
		if a[i] == 0 {
			offset = i
			break
		}
	}

	// If no zero found (should be impossible per problem properties unless all start non-zero and stay... which implies infinite energy?),
	// but strictly decreasing sum implies eventually 0.
	if offset == -1 {
		// Fallback, output nothing
		fmt.Fprintln(w, "0")
		fmt.Fprintln(w)
		return
	}

	survivors := []int{}

	type Mode int
	const (
		Stable Mode = 0
		Stream Mode = 1
	)

	// State machine
	// We start processing from the element at offset.
	// Since a[offset] == 0, it acts as a reset.
	// Effectively, the node at `offset` is dead/stable-zero.
	// It outputs 0 damage.
	// So the initial state for the next node is Stable Source with value 0.
	
	currMode := Stable
	stableVal := 0
	var streamList []int

	// We iterate n times. The first iteration handles the zero at offset,
	// setting up the state for the next ones.
	for k := 0; k < n; k++ {
		idx := (offset + k) % n
		hp := a[idx]

		// If current node is dead (0), it resets the chain.
		// It outputs Stable(0) to the next.
		if hp == 0 {
			currMode = Stable
			stableVal = 0
			streamList = nil
			continue
		}

		if currMode == Stable {
			dmg := stableVal
			if dmg == 0 {
				// Receives 0 damage -> Survives
				survivors = append(survivors, idx+1)
				stableVal = hp
				// Mode remains Stable
			} else {
				// Receives constant damage > 0 -> Dies eventually
				// Output is a finite stream of attacks
				// List of values: hp, hp-dmg, hp-2dmg... > 0
				
				// Calculate size to avoid dynamic resize if possible
				cnt := (hp + dmg - 1) / dmg
				if cnt < 0 { cnt = 0 } // Should not happen
				
				streamList = make([]int, 0, cnt)
				val := hp
				for val > 0 {
					streamList = append(streamList, val)
					val -= dmg
				}
				currMode = Stream
			}
		} else {
			// Finite Stream Mode
			survived := true
			outList := make([]int, 0) // Capacity unknown
			
			for _, d := range streamList {
				// Attack with current HP
				if hp > 0 {
					outList = append(outList, hp)
				}
				hp -= d
				if hp <= 0 {
					hp = 0
					survived = false
					break
				}
			}

			if survived {
				survivors = append(survivors, idx+1)
				currMode = Stable
				stableVal = hp
				streamList = nil
			} else {
				currMode = Stream
				streamList = outList
			}
		}
	}

	sort.Ints(survivors)
	fmt.Fprintln(w, len(survivors))
	for j, val := range survivors {
		if j > 0 {
			fmt.Fprint(w, " ")
		}
		fmt.Fprint(w, val)
	}
	fmt.Fprintln(w)
}
```