package main

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

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

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		// // STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)
		ARRAY := make([]int64, n+1)
		BARRAY := make([]int64, n+1)
		for i := 1; i < n+1; i++ {
			fmt.Fscan(input, &ARRAY[i])
			BARRAY[i] = ARRAY[i]
		}

		sort.Slice(ARRAY, func(i, j int) bool {
			return ARRAY[i] > ARRAY[j]
		})

		var sum int64
		indexxx := 0
		for i := n; i > 0; i-- {
			sum = sum + ARRAY[i]
			if sum < ARRAY[i-1] {
				indexxx = i - 1
			}

		}
		fmt.Println(indexxx + 1)
		for i := 1; i < n+1; i++ {
			if BARRAY[i] >= ARRAY[indexxx] {
				fmt.Println(i)
			}
		}

	}

}

// ZERO := 0
// ONE := 0
// TWO := 0
// for i := 0; i < n; i++ {
// 	fmt.Fscan(input, &ARRAY[i])
// 	if ARRAY[i]%3 == 0 {
// 		ZERO = ZERO + 1
// 	}
// 	if ARRAY[i]%3 == 1 {
// 		ONE = ONE + 1
// 	}
// 	if ARRAY[i]%3 == 2 {
// 		TWO = TWO + 1
// 	}
// }

// k := int(n / 3)

// if ONE == k && TWO == k && ZERO == k {
// 	fmt.Println(0)
// } else {
// 	if ONE == k || TWO == k || ZERO == k {
// 		if ONE == k {
// 			if TWO > ZERO {
// 				fmt.Println(TWO - k)
// 			} else {
// 				fmt.Println(2*TWO - 2*k)
// 			}
// 		}
// 		if TWO == k {
// 			if ZERO > ONE {
// 				fmt.Println(ZERO - k)
// 			} else {
// 				fmt.Println(2*ZERO - 2*k)
// 			}
// 		}
// 		if ZERO == k {
// 			if ONE > TWO {
// 				fmt.Println(ONE - k)
// 			} else {
// 				fmt.Println(2*ONE - 2*k)
// 			}
// 		}
// 	} else {
// 		if ONE > k {
// 			if ZERO < k {
// 				fmt.Println(ONE - TWO)
// 			} else {
// 				fmt.Println(ZERO - TWO)
// 			}
// 		}else{
// 			if TWO > k{

// 			}
// 		}

// }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int64
			fmt.Fscan(in, &x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.Slice(arr, func(i, j int) bool {
			return arr[i].value < arr[j].value
		})
		sum, lastIn := int64(0), 0
		for j := 0; j < n; j++ {
			if sum < arr[j].value {
				lastIn = j
			}
			sum += arr[j].value
		}
		ans := arr[lastIn:]
		sort.Slice(ans, func(i, j int) bool {
			return ans[i].index < ans[j].index
		})
		fmt.Fprintln(out, len(ans))
		for _, val := range ans {
			fmt.Fprint(out, val.index, " ")
		}
		fmt.Fprintln(out)
	}
}

type Pair struct {
	index int
	value int64
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int64
			fmt.Fscan(in, &x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.Slice(arr, func(i, j int) bool {
			return arr[i].value < arr[j].value
		})
		sum, lastIn := int64(0), 0
		for j := 0; j < n; j++ {
			if sum < arr[j].value {
				lastIn = j
			}
			sum += arr[j].value
		}
		ans := arr[lastIn:]
		sort.Slice(ans, func(i, j int) bool {
			return ans[i].index < ans[j].index
		})
		fmt.Println(len(ans))
		for _, val := range ans {
			fmt.Println(val.index)
		}
	}
}

type Pair struct {
	index int
	value int64
}

package main

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

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

func solve() {
	n := getI()
	a := getInts(n)
	b := make([]int64, n)
	copy(b, a)

	nsort(a...)

	lo := int64(0)
	hi := n - 1

	for lo < hi {
		x := lo + (hi-lo)/2
		// out(">", x, lo, hi)

		pow := a[x]
		win := true
		for i := int64(0); i < n; i++ {
			if i != x {
				if pow < a[i] {
					win = false
					break
				}
				pow += a[i]
			}
		}

		// out(a[x], "win:", win)
		if win {
			hi = x
		} else {
			lo = x + 1
		}
	}

	var res []int64
	for i := int64(0); i < n; i++ {
		if b[i] >= a[lo] {
			res = append(res, i+1)
		}
	}

	out(len(res))
	out(njoin(res...))
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	for i := getI(); i > 0; i-- {
		solve()
	}
}

// !------- HELPERS -------!

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func nsort(data ...int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

func sort(arr []int64, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int64, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int64, N)
	original := make([]int64, N)
	originalSort := make([]int64, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			} else {
				break
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Println(j + 1)
			}
		}
		//fmt.Println(in[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

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

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)

		type e struct {
			v   int64
			idx int
		}
		arr := make([]e, n)
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			arr[i] = e{v, i + 1}
		}
		sort.SliceStable(arr, func(i, j int) bool { return arr[i].v < arr[j].v })
		var tot int64
		var start int
		for i := 0; i < n-1; i++ {
			tot += arr[i].v
			if tot < arr[i+1].v {
				start = i + 1
			}
		}
		if start < 0 {
			fmt.Fprintln(out, 1)
			fmt.Fprintln(out, arr[n-1].idx)
		} else {
			g := make([]int, n-start)
			idx := 0
			for i := start; i < n; i++ {
				g[idx] = arr[i].idx
				idx++
			}

			sort.Ints(g)
			fmt.Fprintln(out, len(g))
			for _, v := range g {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

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

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

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		// // STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)
		ARRAY := make([]int64, n+1)
		BARRAY := make([]int64, n+1)
		for i := 1; i < n+1; i++ {
			fmt.Fscan(input, &ARRAY[i])
			BARRAY[i] = ARRAY[i]
		}

		sort.Slice(ARRAY, func(i, j int) bool {
			return ARRAY[i] > ARRAY[j]
		})

		var sum int64
		indexx := 0
		for i := n; i > 0; i-- {
			sum = sum + ARRAY[i]
			if sum < ARRAY[i-1] {
				indexx = i - 1
			}

		}
		fmt.Println(indexx + 1)
		for i := 1; i < n+1; i++ {
			if BARRAY[i] >= ARRAY[indexx] {
				fmt.Println(i)
			}
		}

	}

}

// ZERO := 0
// ONE := 0
// TWO := 0
// for i := 0; i < n; i++ {
// 	fmt.Fscan(input, &ARRAY[i])
// 	if ARRAY[i]%3 == 0 {
// 		ZERO = ZERO + 1
// 	}
// 	if ARRAY[i]%3 == 1 {
// 		ONE = ONE + 1
// 	}
// 	if ARRAY[i]%3 == 2 {
// 		TWO = TWO + 1
// 	}
// }

// k := int(n / 3)

// if ONE == k && TWO == k && ZERO == k {
// 	fmt.Println(0)
// } else {
// 	if ONE == k || TWO == k || ZERO == k {
// 		if ONE == k {
// 			if TWO > ZERO {
// 				fmt.Println(TWO - k)
// 			} else {
// 				fmt.Println(2*TWO - 2*k)
// 			}
// 		}
// 		if TWO == k {
// 			if ZERO > ONE {
// 				fmt.Println(ZERO - k)
// 			} else {
// 				fmt.Println(2*ZERO - 2*k)
// 			}
// 		}
// 		if ZERO == k {
// 			if ONE > TWO {
// 				fmt.Println(ONE - k)
// 			} else {
// 				fmt.Println(2*ONE - 2*k)
// 			}
// 		}
// 	} else {
// 		if ONE > k {
// 			if ZERO < k {
// 				fmt.Println(ONE - TWO)
// 			} else {
// 				fmt.Println(ZERO - TWO)
// 			}
// 		}else{
// 			if TWO > k{

// 			}
// 		}

// }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1490E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct {
		v int64
		i int
	}

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].v)
			a[i].i = i + 1
		}
		sort.Slice(a, func(i, j int) bool { return a[i].v < a[j].v })
		s, st := int64(0), 0
		for i, p := range a {
			if s < p.v {
				st = i
			}
			s += p.v
		}
		Fprintln(out, n-st)
		a = a[st:]
		sort.Slice(a, func(i, j int) bool { return a[i].i < a[j].i })
		for _, v := range a {
			Fprint(out, v.i, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		res := sol(n, a)
		printf("%d\n", len(res))
		for _, d := range res {
			printf("%d ", d)
		}
		printf("\n")
	}
}

func sol(n int64, a []int64) []int64 {
	s := make([]int64, n)
	copy(s, a)
	sort.Slice(s, func(il, ir int) bool {
		return s[il] < s[ir]
	})
	min := findMin(s)
	ret := []int64{}
	for i := range a {
		if a[i] >= min {
			ret = append(ret, int64(i)+1)
		}
	}
	return ret
}

func findMin(s []int64) int64 {
	sum := int64(0)
	for _, i := range s {
		sum += i
	}
	for i := len(s) - 1; i >= 0; i-- {
		if sum-s[i] < s[i] {
			return s[i]
		}
		sum -= s[i]
	}
	return -1
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int64
			fmt.Fscan(in, &x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.Slice(arr, func(i, j int) bool {
			return arr[i].value < arr[j].value
		})
		sum, lastIn := int64(0), 0
		for j := 0; j < n; j++ {
			if sum < arr[j].value {
				lastIn = j
			}
			sum += arr[j].value
		}
		ans := arr[lastIn:]
		sort.Slice(ans, func(i, j int) bool {
			return ans[i].index < ans[j].index
		})
		fmt.Fprintln(out, len(ans))
		for _, val := range ans {
			fmt.Fprint(out, val, " ")
		}
		fmt.Fprintln(out)
	}
}

type Pair struct {
	index int
	value int64
}

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)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int
			fmt.Scan(&x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i].value < arr[j].value {
				return true
			}
			if arr[i].value == arr[j].value {
				if arr[i].index <= arr[j].index {
					return true
				}
				return false
			}
			return false
		})
		var ans []int
		// cumulative sum store of the array is needed and then traverse from back
		cumSum := 0
		for j := 0; j < n-1; j++ {
			cumSum += arr[j].value
			if cumSum >= arr[j+1].value {
				ans = append(ans, arr[j].index)
			}
		}
		ans = append(ans, arr[n-1].index)
		//var ans []int
		//for j := n - 1; j >= 0; j-- {
		//	ans = append(ans, arr[j].index)
		//	if arr[j].value > cumSum[j-1] {
		//		break
		//	}
		//}
		sort.Slice(ans, func(i, j int) bool {
			if ans[i] < ans[j] {
				return true
			}
			return false
		})
		fmt.Println(len(ans))
		for _, val := range ans {
			fmt.Print(val)
			fmt.Print(" ")
		}
		fmt.Println()
	}
}

type Pair struct {
	index int
	value int
}

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)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int
			fmt.Scan(&x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i].value < arr[j].value {
				return true
			}
			if arr[i].value == arr[j].value {
				if arr[i].index <= arr[j].index {
					return true
				}
				return false
			}
			return false
		})
		var ans []int
		// cumulative sum store of the array is needed and then traverse from back
		cumSum := 0
		for j := 0; j < n-1; j++ {
			cumSum += arr[j].value
			if cumSum >= arr[j+1].value {
				ans = append(ans, arr[j].index)
			}
		}
		ans = append(ans, arr[n-1].index)
		//var ans []int
		//for j := n - 1; j >= 0; j-- {
		//	ans = append(ans, arr[j].index)
		//	if arr[j].value > cumSum[j-1] {
		//		break
		//	}
		//}
		sort.Slice(ans, func(i, j int) bool {
			if ans[i] < ans[j] {
				return true
			}
			return false
		})
		fmt.Println(len(ans))
		for _, val := range ans {
			fmt.Println(val)
		}
	}
}

type Pair struct {
	index int
	value int
}

package main

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

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

func solve() {
	n := getI()
	a := getInts(n)
	nsort(a...)

	lo := int64(0)
	hi := n

	for lo < hi {
		x := lo + (hi-lo)/2

		pow := a[x]
		win := true
		for i := int64(0); i < n; i++ {
			if i != x {
				if pow < a[i] {
					win = false
					break
				}
				pow += a[i]
			}
		}

		if win {
			hi = x
		} else {
			lo = x + 1
		}
	}

	out(n - lo)
	for i := lo + 1; i <= n; i++ {
		printf("%d ", i)
	}
	out()
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	for i := getI(); i > 0; i-- {
		solve()
	}
}

// !------- HELPERS -------!

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func nsort(data ...int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

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

func solve() {
	n := getI()
	a := getInts(n)
	nsort(a...)

	lo := int64(0)
	hi := n

	for lo < hi {
		x := lo + (hi-lo)/2

		pow := a[x]
		win := true
		for i := int64(0); i < n; i++ {
			if i != x {
				if pow < a[i] {
					win = false
					break
				}
				pow += a[i]
			}
		}

		if win {
			hi = x
		} else {
			lo = x + 1
		}
	}

	out(n - lo)
	out(njoin(a[lo:]...))
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	for i := getI(); i > 0; i-- {
		solve()
	}
}

// !------- HELPERS -------!

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func nsort(data ...int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	for cases > 0 {
		cases--

		n := getI()
		a := getInts(n)

		if n == 1 {
			out(1)
			out(1)
			continue
		}

		sortInts(a)
		var count int64
		for i := int64(0); i < n; i++ {
			solve(a[:i+1], a[i+1:], &count)
		}

		out(count)
		var result []int64
		for i := int64(0); i < n; i++ {
			if a[i] > n-count {
				result = append(result, i+1)
			}
		}
		out(strings.Trim(fmt.Sprint(result), "[]"))
	}
}

func solve(l, r []int64, c *int64) {
	if len(r) == 0 {
		*c++
		return
	}
	var sumLeft int64
	for i := 0; i < len(l); i++ {
		sumLeft += l[i]
	}
	if sumLeft >= r[0] {
		newLeft := []int64{sumLeft + r[0]}
		solve(newLeft, r[1:], c)
	}
}

// !------- HELPERS -------!

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	for cases > 0 {
		cases--

		n := getI()
		a := getInts(n)

		if n == 1 {
			out(1)
			out(1)
			continue
		}

		winners := make([]bool, n)
		for i := int64(0); i < n; i++ {
			for j := i + 1; j < n; j++ {
				idx := lowerBound(a, a[i]+a[j])
				if a[i] > a[j] {
					winners[i] = true
				}
				if a[i] == a[j] {
					winners[i] = true
					winners[j] = true
				}
				if a[i] < a[j] {
					winners[j] = true
				}

				if int64(idx) < n {
					winners[idx] = true
				}
			}
		}
		var result []int64
		var count int64
		forEach(n, func(i int64) {
			if winners[i] {
				count++
				result = append(result, i+1)
			}
		})
		out(count)
		out(strings.Trim(fmt.Sprint(result), "[]"))
	}
}

// !------- HELPERS -------!

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	forEach(cases, func(i int64) {
		n := getI()
		a := getInts(n)
		winners := make([]bool, n)
		for i := int64(0); i < n; i++ {
			for j := i + 1; j < n; j++ {
				idx := lowerBound(a, a[i]+a[j])
				if a[i] > a[j] {
					winners[i] = true
				}
				if a[i] == a[j] {
					winners[i] = true
					winners[j] = true
				}
				if a[i] < a[j] {
					winners[j] = true
				}

				if int64(idx) < n {
					winners[idx] = true
				}
			}
		}
		var result []int64
		var count int64
		forEach(n, func(i int64) {
			if winners[i] {
				count++
				result = append(result, i+1)
			}
		})
		out(count)
		out(strings.Trim(fmt.Sprint(result), "[]"))
	})
}

// !------- HELPERS -------!

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

func sort(arr []int64, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int64, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int64, N)
	original := make([]int64, N)
	originalSort := make([]int64, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			} else {
				break
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Println(j + 1)
			}
		}
		fmt.Println(in[0:n])
		fmt.Println(originalSort[0:n])
	}
}

package main

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

func sort(arr []int64, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int64, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int64, N)
	original := make([]int64, N)
	originalSort := make([]int64, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Println(j + 1)
			}
		}
		//fmt.Println(input[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

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

func sort(arr []int, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int, N)
	original := make([]int, N)
	originalSort := make([]int, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Print(j + 1)
				if j < n-1 {
					fmt.Print(" ")
				}
			}
		}
		fmt.Println()
		//fmt.Println(input[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

import (
	"fmt"
)

func sort(arr []int, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var test int
	fmt.Scanf("%d", &test)
	const N = 200005
	input := make([]int, N)
	original := make([]int, N)
	originalSort := make([]int, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Scanf("%d", &n)
		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &input[j])
			original[j] = input[j]
		}
		sort(input[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = input[j]
		}
		for j := n - 2; j >= 0; j-- {
			input[j] += input[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if input[j] >= originalSort[j-1] {
				lst = originalSort[j]
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Print(j + 1)
				if j < n-1 {
					fmt.Print(" ")
				}
			}
		}
		fmt.Println()
		//fmt.Println(input[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

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

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)

		type e struct {
			v   int64
			idx int
		}
		arr := make([]e, n)
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			arr[i] = e{v, i + 1}
		}
		sort.SliceStable(arr, func(i, j int) bool { return arr[i].v < arr[j].v })
		var tot int64
		start := -1
		for i := 0; i < n-1; i++ {
			tot += arr[i].v
			if tot >= arr[i+1].v {
				start = i
				break
			}
		}
		if start < 0 {
			fmt.Fprintln(out, 1)
			fmt.Fprintln(out, arr[n-1].idx)
		} else {
			g := make([]int, n-start)
			idx := 0
			for i := start; i < n; i++ {
				g[idx] = arr[i].idx
				idx++
			}

			sort.Ints(g)
			fmt.Fprintln(out, len(g))
			for _, v := range g {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}


package main

import "fmt"

type Pair struct {
	first, second int
}

type Node struct {
	x1, y1, x2, y2 int
}

var m = map[rune]Pair{
	'N': {+1, 0},
	'S': {-1, 0},
	'W': {0, -1},
	'E': {0, +1},
}

func solve() {
	var s string
	fmt.Scanf("%s\n", &s)
	x, y := 0, 0
	var q = map[Node]bool{}
	ans := 0
	for _, c := range s {
		dx, dy := m[c].first, m[c].second
		if _, ok := q[Node{x, y, x + dx, y + dy}]; ok {
			ans += 1
		} else {
			ans += 5
			q[Node{x, y, x + dx, y + dy}] = true
			q[Node{x + dx, y + dy, x, y}] = true
		}
		x += dx
		y += dy
	}
	fmt.Println(ans)
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

// https://codeforces.com/contest/1351/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var path string
	fmt.Fscanln(input, &path)
	n := int64(len(path))
	m := make(map[int64]bool)

	r, c, n2 := int64(0), int64(0), n*n
	ans := 0
	for i := int64(0); i < n; i++ {
		switch path[i] {
		case 'S':
			if m[n2*(r*n+c) + (r+1)*n+c] {
				ans++
			} else {
				ans += 5
				m[n2*(r*n+c) + (r+1)*n+c] = true
				m[(r*n+c) + n2*((r+1)*n+c)] = true
			}
			r++
		case 'N':
			if m[n2*(r*n+c) + (r-1)*n+c] {
				ans++
			} else {
				ans += 5
				m[n2*(r*n+c) + (r-1)*n+c] = true
				m[(r*n+c) + n2*((r-1)*n+c)] = true
			}
			r--
		case 'W':
			if m[n2*(r*n+c) + r*n+c - 1] {
				ans++
			} else {
				ans += 5
				m[n2*(r*n+c) + r*n+c - 1] = true
				m[(r*n+c) + n2*(r*n+c - 1)] = true
			}
			c--
		case 'E':
			if m[n2 *(r*n+c) + r*n+c + 1] {
				ans++
			} else {
				ans += 5
				m[n2 *(r*n+c) + r*n+c + 1] = true
				m[(r*n+c) + n2*(r*n+c + 1)] = true
			}
			c++
		}
	}

	fmt.Println(ans)
}

package main

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

func abs(i int64) int64 {
	if i < 0 {
		return -i
	}

	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	ini := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	ins := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := ini(); t > 0; t-- {
		s := ins()

		currx := 0
		curry := 0

		var v int64

		m := make(map[int64]bool)
		m[0] = true

		val := 0

		var dx int64 = 0
		var dy int64 = 0

		for i := range s {

			dx, dy = 0, 0

			switch s[i] {
			case 'N':
				dy++
			case 'S':
				dy--
			case 'E':
				dx++
			case 'W':
				dx--
			}

			v = (int64(2*currx) + dx)*100000 + int64(2*curry) + dy

			if m[v] == true {
				val++
			} else {
				val += 5
			}

			m[v] = true
			currx += int(dx)
			curry += int(dy)
		}

		fmt.Println(val)
	}
}

package main

import "fmt"

type Coordinate struct {
	x, y int
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		var query string
		fmt.Scan(&query)

		c := Coordinate{}
		visited := map[[2]Coordinate]bool{}
		directions := map[byte]Coordinate{
			'N': {0, 1},
			'S': {0, -1},
			'E': {1, 0},
			'W': {-1, 0},
		}
		var ans int

		for _, move := range query {
			st := c
			dir := directions[byte(move)]
			c.x += dir.x
			c.y += dir.y
			if pp, qq := [2]Coordinate{st, c}, [2]Coordinate{c, st}; visited[pp] || visited[qq] {
				ans += 1
			} else {
				visited[pp] = true
				visited[qq] = true
				ans += 5
			}
		}
		fmt.Println(ans)
		TC--
	}
}

package main

import "fmt"

type Pair struct {
	x, y int
}

type Segment struct {
	p1, p2 Pair
}

var direction = map[byte]Pair{
	'N': Pair{1, 0},
	'S': Pair{-1, 0},
	'E': Pair{0, 1},
	'W': Pair{0, -1},
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		visited := map[Segment]bool{}
		var sequence []byte
		fmt.Scan(&sequence)

		var p Pair
		var ans int
		for _, b := range sequence {
			start := p
			dirP := direction[b]
			p.x += dirP.x
			p.y += dirP.y

			pp := Segment{start, p}
			qq := Segment{p, start}
			if v1, v2 := visited[pp], visited[qq]; v1 && v2 {
				ans++
			} else {
				visited[pp] = true
				visited[qq] = true
				ans += 5
			}
		}
		fmt.Println(ans)
		TC--
	}
}

package main

import (
	"fmt"
)

func getStringPair(s1, s2 string) string {
	var x1, y1, x2, y2 int
	fmt.Sscanf(s1, "%d,%d", &x1, &y1)
	fmt.Sscanf(s2, "%d,%d", &x2, &y2)
	if x1 < x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
	} else if x1 > x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
	} else {
		if y1 < y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		} else if y1 > y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
		} else {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		}
	}
}

func solve() {
	var path string
	fmt.Scan(&path)

	var x, y int
	currPos := fmt.Sprintf("%d,%d", x, y)
	grid := map[string]bool{currPos: true} // technically used as a set

	var sum int
	for i := 0; i < len(path); i++ {
		newY := y
		newX := x
		char := path[i]
		if char == 'N' {
			newY++
		}
		if char == 'S' {
			newY--
		}
		if char == 'E' {
			newX++
		}
		if char == 'W' {
			newX--
		}

		newPos := fmt.Sprintf("%d,%d", newX, newY)
		edge := getStringPair(currPos, newPos)
		if _, ok := grid[edge]; ok {
			sum += 1
		} else {
			grid[edge] = true
			sum += 5
		}
		x = newX
		y = newY
		currPos = newPos
	}
	fmt.Println(sum)
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		solve()
		TC--
	}
}

/*
URL:
https://codeforces.com/problemset/problem/1351/C
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int
	S []rune
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		S = ReadRuneSlice()

		solve()
	}
}

func solve() {
	cx, cy := 0, 0
	memo := make(map[Coord]bool)

	ans := 0
	for _, r := range S {
		nx, ny := cx, cy
		if r == 'S' {
			ny--
		} else if r == 'N' {
			ny++
		} else if r == 'W' {
			nx--
		} else {
			nx++
		}

		c := Coord{x: cx + nx, y: cy + ny}
		if _, ok := memo[c]; ok {
			ans++
		} else {
			ans += 5
		}

		memo[c] = true
		cx, cy = nx, ny
	}

	fmt.Println(ans)
}

type Coord struct {
	x, y int
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1351C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := [...]pair{
		'W': {-1, 0},
		'E': {1, 0},
		'S': {0, -1},
		'N': {0, 1},
	}

	var t int
	var s []byte
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &s)
		ans := 0
		vis := map[[2]pair]bool{}
		p := pair{}
		for _, b := range s {
			st := p
			d := dir4[b]
			p.x += d.x
			p.y += d.y
			if pp, qq := [2]pair{st, p}, [2]pair{p, st}; vis[pp] || vis[qq] {
				ans++
			} else {
				vis[pp] = true
				vis[qq] = true
				ans += 5
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

type path struct {
    lat int
    lon int
    hor bool
}

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int
        vis := map[path]bool{}
        for _, c := range s {
            var d path
            switch c {
                case 'N':
                    lat++
                    d = path{lat, lon, false}
                case 'S':
                    d = path{lat, lon, false}
                    lat--
                case 'E':
                    lon++
                    d = path{lat, lon, true}
                case 'W':
                    d = path{lat, lon, true}
                    lon--
            }
            if vis[d] {
                time += 1
            } else {
                time += 5
                vis[d] = true
            }
        }
        fmt.Println(time)
    }
}

package main

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

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int64
        m := map[int64]bool{}
        for _, c := range s {
            var d int64
            switch c {
                case 'N': lat++; d = 200000 * lat + lon
                case 'S': d = 200000 * lat + lon; lat--
                case 'E': lon++; d = 200000 * lat + lon + 200000000000
                case 'W': d = 200000 * lat + lon + 200000000000; lon--
            }
            if m[d] {
                time += 1
            } else {
                time += 5
                m[d] = true
            }
        }
        fmt.Println(time)
    }
}

package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		s := getNextString(scanner)
		vn := map[uint64]int{}
		vs := map[uint64]int{}
		ve := map[uint64]int{}
		vw := map[uint64]int{}
		n := len(s)
		y := n + 1
		x := n + 1
		ans := 0
		for j := 0; j < n; j++ {
			k := key(y, x)
			switch s[j] {
			case 'N':
				ans += visit(k, key(y+1, x), vn, vs)
				y++
			case 'E':
				ans += visit(k, key(y, x+1), ve, vw)
				x++
			case 'W':
				ans += visit(k, key(y, x-1), vw, ve)
				x--
			case 'S':
				ans += visit(k, key(y-1, x), vs, vn)
				y--
			}
		}
		fmt.Fprintln(writer, ans)
	}
}

func visit(k1, k2 uint64, v1, v2 map[uint64]int) int {
	if v1[k1] == 0 && v2[k2] == 0 {
		v1[k1] = 1
		return 5
	}

	return 1
}

func key(y, x int) uint64 {
	return uint64(y)<<32 | uint64(x)
}

package main

import "fmt"

func solve() {
	var path string
	fmt.Scan(&path)
	var x, y int
	grid := map[string]bool{fmt.Sprintf("%d,%d", x, y): true} // technically used as a set

	var sum int
	for i := 0; i < len(path); i++ {
		char := path[i]
		if char == 'N' {
			y++
		}
		if char == 'S' {
			y--
		}
		if char == 'E' {
			x++
		}
		if char == 'W' {
			x--
		}

		newPos := fmt.Sprintf("%d,%d", x, y)
		if _, ok := grid[newPos]; ok {
			sum += 1
		} else {
			grid[newPos] = true
			sum += 5
		}
	}
	fmt.Println(sum)
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		solve()
		TC--
	}
}

package main

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

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int64
        m := map[int64]bool{
            0: true,
        }
        for _, c := range s {
            switch c {
            case 'N': lat++
            case 'S': lat--
            case 'E': lon++
            case 'W': lon--
            }
            v := m[200000 * lat + lon]
            if v {
                time += 1
            } else {
                time += 5
                m[200000 * lat + lon] = true
            }
        }
        fmt.Println(time)
    }
}

package main

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

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int64
        m := map[int64]bool{
            0: true,
        }
        for _, c := range s {
            var d int64
            switch c {
                case 'N': lat++; d = 200000 * lat + lon
                case 'S': d = 200000 * lat + lon; lat--
                case 'E': lon++; d = 200000 * lat + lon + 200000000000
                case 'W': d = 200000 * lat + lon + 200000000000; lon--
            }
            if m[d] {
                time += 1
            } else {
                time += 5
                m[d] = true
            }
        }
        fmt.Println(time)
    }
}

package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		s := getNextString(scanner)
		v := map[uint64]int{}
		n := len(s)
		y := n + 1
		x := n + 1
		v[key(y, x)] = 4
		ans := 0
		for j := 0; j < n; j++ {
			switch s[j] {
			case 'N':
				y++
			case 'E':
				x++
			case 'W':
				x--
			case 'S':
				y--
			}
			ans += 5 - v[key(y, x)]
			v[key(y, x)] = 4
		}
		fmt.Fprintln(writer, ans)
	}
}

func key(y, x int) uint64 {
	return uint64(y)<<32 | uint64(x)
}

package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		s := getNextString(scanner)
		v := map[uint64]int{}
		y := int(1e5)
		x := int(1e5)
		v[key(y, x)] = 4
		n := len(s)
		ans := 0
		for j := 0; j < n; j++ {
			switch s[j] {
			case 'N':
				y++
			case 'E':
				x++
			case 'W':
				x--
			case 'S':
				y--
			}
			ans += 5 - v[key(y, x)]
			v[key(y, x)] = 4
		}
		fmt.Fprintln(writer, ans)
	}
}

func key(y, x int) uint64 {
	return uint64(y)<<32 | uint64(x)
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	ini := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	ins := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := ini(); t > 0; t-- {
		s := ins()

		currx := 0
		curry := 0

		var v int64

		m := make(map[int64]bool)
		m[0] = true

		val := 0

		for i := range s {
			switch s[i] {
			case 'N':
				curry++
			case 'S':
				curry--
			case 'E':
				currx++
			case 'W':
				currx--
			}

			v = int64(currx)*100000 + int64(curry)

			if m[v] == true {
				val++
			} else {
				val += 5
				m[v] = true
			}
		}

		fmt.Println(val)
	}
}

package main

import (
	"fmt"
	"strconv"
)

func getStringPair(s1, s2 string) string {
	x1, _ := strconv.Atoi(s1[0:1])
	y1, _ := strconv.Atoi(s1[2:])

	x2, _ := strconv.Atoi(s1[0:1])
	y2, _ := strconv.Atoi(s1[2:])

	if x1 < x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
	} else if x1 > x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
	} else {
		if y1 < y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		} else if y1 > y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
		} else {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		}
	}
}

func solve() {
	var path string
	fmt.Scan(&path)

	var x, y int
	currPos := fmt.Sprintf("%d,%d", x, y)
	grid := map[string]bool{currPos: true} // technically used as a set

	var sum int
	for i := 0; i < len(path); i++ {
		newY := y
		newX := x
		char := path[i]
		if char == 'N' {
			newY++
		}
		if char == 'S' {
			newY--
		}
		if char == 'E' {
			newX++
		}
		if char == 'W' {
			newX--
		}

		newPos := fmt.Sprintf("%d,%d", newX, newY)
		edge := getStringPair(currPos, newPos)
		if _, ok := grid[edge]; ok {
			sum += 1
		} else {
			grid[edge] = true

			sum += 5
		}
		x = newX
		y = newY
		currPos = newPos
	}
	fmt.Println(sum)
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		solve()
		TC--
	}
}


package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
type pair struct{ v, d int }
type hp []pair

func (h hp) Len() int              { return len(h) }
func (h hp) Less(i, j int) bool    { return h[i].d < h[j].d }
func (h hp) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{})   { *h = append(*h, v.(pair)) }
func (h *hp) Pop() (v interface{}) { a := *h; *h, v = a[:len(a)-1], a[len(a)-1]; return }
func (h *hp) push(v pair)          { heap.Push(h, v) }
func (h *hp) pop() pair            { return heap.Pop(h).(pair) }

func CF1486E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const inf int = 1e9
	type nb struct{ to, wt int }

	var n, m, v, w, wt int
	Fscan(in, &n, &m)
	g := make([][]nb, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		g[v] = append(g[v], nb{w, wt})
		g[w] = append(g[w], nb{v, wt})
	}
	dist := make([]int, n)
	mi := make([]int, n)
	for i := range dist {
		dist[i] = inf
		mi[i] = inf
	}
	dist[0] = 0
	q := hp{{}}
	for len(q) > 0 {
		p := q.pop()
		v := p.v
		if p.d > dist[v] {
			continue
		}
		for _, e := range g[v] {
			w, wt := e.to, e.wt
			if wt >= mi[w] {
				continue
			}
			mi[w] = wt
			for _, e2 := range g[w] {
				u := e2.to
				if newD := dist[v] + (wt+e2.wt)*(wt+e2.wt); newD < dist[u] {
					dist[u] = newD
					q.push(pair{u, newD})
				}
			}
		}
	}
	for _, v := range dist {
		if v == inf {
			v = -1
		}
		Fprint(out, v, " ")
	}
}

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

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int64]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}
	pq := &PriorityQueue{}

	dist[0] = 0
	start := pqitem{}
	heap.Push(pq, start)

	for pq.Len() > 0 {
		currState := heap.Pop(pq).(pqitem)

		hashstate := [2]int64{currState.node, currState.prevWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if currState.isMiddle {
			for _, e := range adj[currState.node] {
				edgeWeight := (currState.prevWeight + e.weight)
				d := currState.fromDist + edgeWeight*edgeWeight
				if dist[e.next] > d {
					dist[e.next] = d
					heap.Push(pq, pqitem{
						node:       e.next,
						isMiddle:   false,
						fromDist:   d,
						prevWeight: 0,
					})
				}
			}
		} else {
			for _, e := range adj[currState.node] {
				heap.Push(pq, pqitem{
					node:       e.next,
					isMiddle:   true,
					fromDist:   dist[currState.node],
					prevWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int64
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int64
}

type PriorityQueue []pqitem

type pqitem struct {
	node       int64
	isMiddle   bool
	fromDist   int64
	prevWeight int64
}

func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].isMiddle {
		return true
	}
	if pq[j].isMiddle {
		return false
	}
	return pq[i].fromDist < pq[j].fromDist
}

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Swap(i, j int) { pq[i], pq[j] = pq[j], pq[i] }

func (pq *PriorityQueue) Push(x interface{}) { *pq = append(*pq, x.(pqitem)) }

func (pq *PriorityQueue) Pop() interface{} {
	ret := (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return ret
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[int64]bool)
	visitedMiddle := make(map[[2]int64]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}
	pq := &PriorityQueue{}

	start := pqitem{isMiddle: false}
	dist[0] = 0
	heap.Push(pq, start)

	for pq.Len() > 0 {
		currState := heap.Pop(pq).(pqitem)
		if currState.isMiddle {
			hashstate := [2]int64{currState.node, currState.prevWeight}
			if visitedMiddle[hashstate] {
				continue
			}
			visitedMiddle[hashstate] = true
			for _, e := range adj[currState.node] {
				edgeWeight := (currState.prevWeight + e.weight) * (currState.prevWeight + e.weight)
				if dist[e.next] > currState.fromDist+edgeWeight {
					dist[e.next] = currState.fromDist + edgeWeight
					heap.Push(pq, pqitem{
						node:       e.next,
						isMiddle:   false,
						fromDist:   dist[e.next],
						prevWeight: -1,
					})
				}
			}
		} else {
			if visited[currState.node] {
				continue
			}
			visited[currState.node] = true
			for _, e := range adj[currState.node] {
				heap.Push(pq, pqitem{
					node:       e.next,
					isMiddle:   true,
					fromDist:   dist[currState.node],
					prevWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int64
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int64
}

type PriorityQueue []pqitem

type pqitem struct {
	node       int64
	isMiddle   bool
	fromDist   int64
	prevWeight int64
}

func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].isMiddle {
		return true
	}
	if pq[j].isMiddle {
		return false
	}
	return pq[i].fromDist < pq[j].fromDist
}

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Swap(i, j int) { pq[i], pq[j] = pq[j], pq[i] }

func (pq *PriorityQueue) Push(x interface{}) { *pq = append(*pq, x.(pqitem)) }

func (pq *PriorityQueue) Pop() interface{} {
	ret := (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return ret
}

package main

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

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}

	pq := &minheap{}
	pq.push(state{})
	dist[0] = 0

	for pq.len() > 0 {
		s := pq.pop()

		hashstate := [2]int{s.node, s.prevEdgeWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if s.middle == 1 {
			for _, e := range adj[s.node] {
				cost := int64(s.prevEdgeWeight + e.weight)
				d := s.dist + cost*cost
				if dist[e.next] > d {
					dist[e.next] = d
					pq.push(state{
						node:           e.next,
						middle:         s.middle ^ 1,
						dist:           d,
						prevEdgeWeight: 0,
					})
				}
			}
		} else {
			for _, e := range adj[s.node] {
				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[s.node],
					prevEdgeWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int
}

type state struct {
	middle         byte
	node           int
	dist           int64
	prevEdgeWeight int
}

func lessop(s0, s1 state) bool {
	if s0.middle == 1 {
		return true
	}
	if s1.middle == 1 {
		return false
	}
	return s0.dist < s1.dist
}

type minheap []state

func (h *minheap) push(x state) {
	*h = append(*h, x)
	h.up(len(*h) - 1)
}

func (h *minheap) pop() state {
	old := *h
	n := len(old)
	top := old[0]

	old[0], old[n-1] = old[n-1], old[0]
	*h = old[:n-1]
	h.down(0)

	return top
}

func (h minheap) up(j int) {
	for j > 0 {
		i := (j - 1) / 2
		if !lessop(h[j], h[i]) {
			break
		}
		h[i], h[j] = h[j], h[i]
		j = i
	}
}

func (h minheap) down(j int) {
	i := j
	for {
		mini, l, r := i, 2*i+1, 2*i+2
		if l < len(h) && lessop(h[l], h[mini]) {
			mini = l
		}
		if r < len(h) && lessop(h[r], h[mini]) {
			mini = r
		}
		if mini == i {
			break
		}
		h[i], h[mini] = h[mini], h[i]
		i = mini
	}
}

func (h *minheap) len() int {
	return len(*h)
}

package main

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

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}

	pq := &minheap{}
	pq.push(state{})
	dist[0] = 0

	for pq.len() > 0 {
		s := pq.pop()

		hashstate := [2]int{s.node, s.prevEdgeWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if s.middle == 1 {
			for _, e := range adj[s.node] {
				cost := int64(s.prevEdgeWeight + e.weight)
				d := s.dist + cost*cost
				if dist[e.next] > d {
					dist[e.next] = d
					pq.push(state{
						node:           e.next,
						middle:         s.middle ^ 1,
						dist:           dist[e.next],
						prevEdgeWeight: 0,
					})
				}
			}
		} else {
			for _, e := range adj[s.node] {
				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[s.node],
					prevEdgeWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int
}

type state struct {
	middle         byte
	node           int
	dist           int64
	prevEdgeWeight int
}

func lessop(s0, s1 state) bool {
	if s0.middle == 1 {
		return true
	}
	if s1.middle == 1 {
		return false
	}
	return s0.dist < s1.dist
}

type minheap []state

func (h *minheap) push(x state) {
	*h = append(*h, x)
	h.up(len(*h) - 1)
}

func (h *minheap) pop() state {
	old := *h
	n := len(old)
	top := old[0]

	old[0], old[n-1] = old[n-1], old[0]
	*h = (*h)[:n-1]
	h.down(0)

	return top
}

func (h minheap) up(j int) {
	for j > 0 {
		i := (j - 1) / 2
		if !lessop(h[j], h[i]) {
			break
		}
		h[i], h[j] = h[j], h[i]
		j = i
	}
}

func (h minheap) down(j int) {
	i := j
	for {
		mini, l, r := i, 2*i+1, 2*i+2
		if l < len(h) && lessop(h[l], h[mini]) {
			mini = l
		}
		if r < len(h) && lessop(h[r], h[mini]) {
			mini = r
		}
		if mini == i {
			break
		}
		h[i], h[mini] = h[mini], h[i]
		i = mini
	}
}

func (h *minheap) len() int {
	return len(*h)
}

package main

import (
	"bufio"
	"bytes"
	"container/heap"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, m := readTwoNums(reader)

	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 3)
	}

	res := solve(n, m, E)

	var buf bytes.Buffer

	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 1 << 60

func solve(n int, m int, E [][]int) []int64 {
	g := NewGraph(n, m*2)

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		g.AddEdge(u-1, v-1, int64(w))
		g.AddEdge(v-1, u-1, int64(w))
	}

	mn := make([]int64, n)
	dist := make([]int64, n)

	for i := 0; i < n; i++ {
		mn[i] = INF
		dist[i] = INF
	}

	//mn[0] = 0
	dist[0] = 0

	pq := make(PriorityQueue, 0, n)
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)
		u := cur.value
		if dist[u] < cur.priority {
			continue
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if mn[v] > g.val[i] {
				for j := g.nodes[v]; j > 0; j = g.next[j] {
					x := g.to[j]
					w := g.val[i] + g.val[j]
					if dist[x] > dist[u]+w*w {
						dist[x] = dist[u] + w*w
						heap.Push(&pq, NewItem(x, dist[x]))
					}
				}
				mn[v] = g.val[i]
			}
		}
	}

	for i := 0; i < n; i++ {
		if dist[i] == INF {
			dist[i] = -1
		}
	}
	return dist
}

func solve1(n int, m int, E [][]int) []int64 {
	g := NewGraph(n*51, 2*m*51)

	connect := func(u, v, w int) {
		g.AddEdge(u*51, v*51+w, 0)
		for was := 1; was <= 50; was++ {
			g.AddEdge(u*51+was, v*51, int64(was+w)*int64(was+w))
		}
	}

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		connect(u-1, v-1, w)
		connect(v-1, u-1, w)
	}

	dist := make([]int64, n*51)
	for i := 0; i < len(dist); i++ {
		dist[i] = INF
	}
	pq := make(PriorityQueue, 0, n)
	dist[0] = 0
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)

		u := cur.value

		if dist[u] < cur.priority {
			continue
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if dist[v] > cur.priority+g.val[i] {
				dist[v] = cur.priority + g.val[i]
				heap.Push(&pq, NewItem(v, dist[v]))
			}
		}
	}

	res := make([]int64, n)

	for i := 0; i < n; i++ {
		if dist[51*i] == INF {
			res[i] = -1
		} else {
			res[i] = dist[i*51]
		}
	}

	return res
}

type Graph struct {
	count []int
	nodes []int
	next  []int
	to    []int
	val   []int64
	cur   int
}

func NewGraph(n int, e int) *Graph {
	count := make([]int, n)
	nodes := make([]int, n)
	next := make([]int, e+10)
	to := make([]int, e+10)
	val := make([]int64, e+10)
	return &Graph{count, nodes, next, to, val, 0}
}

func (g *Graph) AddEdge(u, v int, w int64) {
	g.count[u]++
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
	g.val[g.cur] = w
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    int   // The value of the item; arbitrary.
	priority int64 // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

func NewItem(v int, p int64) *Item {
	item := new(Item)
	item.value = v
	item.priority = p
	return item
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, priority int64) {
	item.priority = priority
	heap.Fix(pq, item.index)
}

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
type pair struct{ v, d int }
type hp []pair

func (h hp) Len() int              { return len(h) }
func (h hp) Less(i, j int) bool    { return h[i].d < h[j].d }
func (h hp) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{})   { *h = append(*h, v.(pair)) }
func (h *hp) Pop() (v interface{}) { a := *h; *h, v = a[:len(a)-1], a[len(a)-1]; return }
func (h *hp) push(v pair)          { heap.Push(h, v) }
func (h *hp) pop() pair            { return heap.Pop(h).(pair) }

func CF1486E(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	_i, _n, buf := 0, 0, make([]byte, 1<<12)
	rc := func() byte {
		if _i == _n {
			_n, _ = _r.Read(buf)
			if _n == 0 {
				return 0
			}
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	const inf int = 1e9
	type nb struct{ to, wt int }

	n, m := r(), r()
	g := make([][]nb, n)
	for i := 0; i < m; i++ {
		v, w, wt := r()-1, r()-1, r()
		g[v] = append(g[v], nb{w, wt})
		g[w] = append(g[w], nb{v, wt})
	}
	dist := make([]int, n)
	mi := make([]int, n)
	for i := range dist {
		dist[i] = inf
		mi[i] = inf
	}
	dist[0] = 0
	q := hp{{}}
	for len(q) > 0 {
		p := q.pop()
		v := p.v
		if p.d > dist[v] {
			continue
		}
		for _, e := range g[v] {
			w, wt := e.to, e.wt
			if wt >= mi[w] {
				continue
			}
			mi[w] = wt
			for _, e2 := range g[w] {
				u := e2.to
				if newD := dist[v] + (wt+e2.wt)*(wt+e2.wt); newD < dist[u] {
					dist[u] = newD
					q.push(pair{u, newD})
				}
			}
		}
	}
	for _, v := range dist {
		if v == inf {
			v = -1
		}
		Fprint(out, v, " ")
	}
}

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

package main

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

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}

	pq := &minheap{}
	pq.push(state{})
	dist[0] = 0

	for pq.len() > 0 {
		s := pq.pop()

		hashstate := [2]int{s.node, s.prevEdgeWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if s.middle == 1 {
			for _, e := range adj[s.node] {
				w := int64(s.prevEdgeWeight + e.weight)
				d := s.dist + w*w
				if dist[e.next] > d {
					dist[e.next] = d
				}

				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[e.next],
					prevEdgeWeight: 0,
				})
			}
		} else {
			for _, e := range adj[s.node] {
				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[s.node],
					prevEdgeWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int
}

type state struct {
	middle         byte
	node           int
	dist           int64
	prevEdgeWeight int
}

func lessop(s0, s1 state) bool {
	if s0.middle == 1 {
		return true
	}
	if s1.middle == 1 {
		return false
	}
	return s0.dist < s1.dist
}

type minheap []state

func (h *minheap) push(x state) {
	*h = append(*h, x)
	h.up(len(*h) - 1)
}

func (h *minheap) pop() state {
	old := *h
	n := len(old)
	top := old[0]

	old[0], old[n-1] = old[n-1], old[0]
	*h = old[:n-1]
	h.down(0)

	return top
}

func (h minheap) up(j int) {
	for j > 0 {
		i := (j - 1) / 2
		if !lessop(h[j], h[i]) {
			break
		}
		h[i], h[j] = h[j], h[i]
		j = i
	}
}

func (h minheap) down(j int) {
	i := j
	for {
		mini, l, r := i, 2*i+1, 2*i+2
		if l < len(h) && lessop(h[l], h[i]) {
			mini = l
		}
		if r < len(h) && lessop(h[r], h[i]) {
			mini = r
		}
		if mini == i {
			break
		}
		h[i], h[mini] = h[mini], h[i]
		i = mini
	}
}

func (h *minheap) len() int {
	return len(*h)
}

package main

import (
	"bufio"
	"bytes"
	"container/heap"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, m := readTwoNums(reader)

	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 3)
	}

	res := solve(n, m, E)

	var buf bytes.Buffer

	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 1 << 60

func solve(n int, m int, E [][]int) []int64 {
	g := NewGraph(n, m*2)

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		g.AddEdge(u-1, v-1, int64(w))
		g.AddEdge(v-1, u-1, int64(w))
	}

	mn := make([]int64, n)
	dist := make([]int64, n)

	for i := 0; i < n; i++ {
		mn[i] = INF
		dist[i] = INF
	}

	//mn[0] = 0
	dist[0] = 0

	pq := make(PriorityQueue, 0, n)
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)
		u := cur.value
		if dist[u] < cur.priority {
			continue
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if mn[v] > cur.priority {
				for j := g.nodes[v]; j > 0; j = g.next[j] {
					x := g.to[j]
					w := g.val[i] + g.val[j]
					if dist[x] > dist[u]+w*w {
						dist[x] = dist[u] + w*w
						heap.Push(&pq, NewItem(x, dist[x]))
					}
				}
				mn[v] = cur.priority
			}
		}
	}

	for i := 0; i < n; i++ {
		if dist[i] == INF {
			dist[i] = -1
		}
	}
	return dist
}

func solve1(n int, m int, E [][]int) []int64 {
	g := NewGraph(n*51, 2*m*51)

	connect := func(u, v, w int) {
		g.AddEdge(u*51, v*51+w, 0)
		for was := 1; was <= 50; was++ {
			g.AddEdge(u*51+was, v*51, int64(was+w)*int64(was+w))
		}
	}

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		connect(u-1, v-1, w)
		connect(v-1, u-1, w)
	}

	dist := make([]int64, n*51)
	for i := 0; i < len(dist); i++ {
		dist[i] = INF
	}
	pq := make(PriorityQueue, 0, n)
	dist[0] = 0
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)

		u := cur.value

		if dist[u] < cur.priority {
			continue
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if dist[v] > cur.priority+g.val[i] {
				dist[v] = cur.priority + g.val[i]
				heap.Push(&pq, NewItem(v, dist[v]))
			}
		}
	}

	res := make([]int64, n)

	for i := 0; i < n; i++ {
		if dist[51*i] == INF {
			res[i] = -1
		} else {
			res[i] = dist[i*51]
		}
	}

	return res
}

type Graph struct {
	count []int
	nodes []int
	next  []int
	to    []int
	val   []int64
	cur   int
}

func NewGraph(n int, e int) *Graph {
	count := make([]int, n)
	nodes := make([]int, n)
	next := make([]int, e+10)
	to := make([]int, e+10)
	val := make([]int64, e+10)
	return &Graph{count, nodes, next, to, val, 0}
}

func (g *Graph) AddEdge(u, v int, w int64) {
	g.count[u]++
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
	g.val[g.cur] = w
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    int   // The value of the item; arbitrary.
	priority int64 // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

func NewItem(v int, p int64) *Item {
	item := new(Item)
	item.value = v
	item.priority = p
	return item
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, priority int64) {
	item.priority = priority
	heap.Fix(pq, item.index)
}


package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  paint := make([]int64, n)
  low, high := int64(1000) * 1000 * 1000, int64(1)
  start := 0
  var x int64
  for i := range paint {
    x = getI64()
    if x > high {
      high = x
    }
    if x < low {
      low = x
      start = i
    }
    paint[i] = x
  }
  if low == high {
    writer.WriteString(fmt.Sprintf("%d\n", low * int64(n)))
    return
  }
  count, best := 0, 0
  pos := start
  for {
    pos++
    if pos == n {
      pos = 0
    }
    if pos == start {
      break
    }
    if paint[pos] > low {
      count++
      if count > best {
        best = count
      }
    } else {
      count = 0
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", low * int64(n) + int64(best)))
}

package main

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

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int

    fmt.Fscan(stdin, &n)
    a := make([]int64, n)
    m := int64(1000000001)
    for i := 0; i < n; i++ {
      fmt.Fscan(stdin, &a[i])
      m = min(m, a[i])
    }

    dist := 0
    last := 0
    for i := 0; i < 2*n; i++ {
      if a[i%n] == m {
        dist = max(dist, i - last - 1)
        last = i
      }
    }

    fmt.Println(m*int64(n) + int64(dist))
}

package main

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

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int

    fmt.Fscan(stdin, &n)
    a := make([]int64, n)
    m := int64(1000000001)
    for i := 0; i < n; i++ {
      fmt.Fscan(stdin, &a[i])
      m = min(m, a[i])
    }

    dist := 0
    last := 0
    for i := 0; i < 2*n; i++ {
      if a[i%n] == m {
        fmt.Println(">", i, last, i - last - 1)
        dist = max(dist, i - last - 1)
        last = i
      }
    }

    fmt.Println(m*int64(n) + int64(dist))
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  paint := make([]int, n)
  low, high := 1000 * 1000 * 1000, 1
  start := 0
  var x int
  for i := range paint {
    x = getI()
    if x > high {
      high = x
    }
    if x < low {
      low = x
      start = i
    }
    paint[i] = x
  }
  if low == high {
    writer.WriteString(fmt.Sprintf("%d\n", low * n))
    return
  }
  count, best := 0, 0
  pos := start
  for {
    pos++
    if pos == n {
      pos = 0
    }
    if pos == start {
      break
    }
    if paint[pos] > low {
      count++
      if count > best {
        best = count
      }
    } else {
      count = 0
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", low * n + best))
}